tests: move create_*_file to SystemTestsMixin

This commit is contained in:
Marek Marczykowski-Górecki 2017-06-20 16:14:16 +02:00
والد f56f7d13fb
کامیت 984a070f3e
هیچ کلید شناخته شده ای برای این امضا در پایگاه داده ها یافت نشد
شناسه کلید GPG: 063938BA42CFA724
3فایلهای تغییر یافته به همراه13 افزوده شده و 16 حذف شده

مشاهده پرونده

@ -37,6 +37,7 @@ import functools
import logging
import os
import pathlib
import shlex
import shutil
import subprocess
import sys
@ -962,6 +963,16 @@ class SystemTestsMixin(object):
shutil.rmtree(mountpoint)
subprocess.check_call(['sudo', 'losetup', '-d', loopdev])
def create_local_file(self, filename, content, mode='w'):
with open(filename, mode) as file:
file.write(content)
self.addCleanup(os.unlink, filename)
def create_remote_file(self, vm, filename, content):
self.loop.run_until_complete(vm.run_for_stdio(
'cat > {}'.format(shlex.quote(filename)),
user='root', input=content.encode('utf-8')))
def load_tests(loader, tests, pattern): # pylint: disable=unused-argument
# discard any tests from this module, because it hosts base classes

مشاهده پرونده

@ -20,21 +20,17 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
from distutils import spawn
import asyncio
import multiprocessing
import os
import shlex
import subprocess
import time
import unittest
from distutils import spawn
import qubes.config
import qubes.tests
import qubes.vm.appvm
import qubes.vm.templatevm
import re
TEST_DATA = b"0123456789" * 1024
@ -59,16 +55,6 @@ class TC_00_AppVMMixin(qubes.tests.SystemTestsMixin):
self.loop.run_until_complete(self.testvm2.create_on_disk())
self.app.save()
def create_local_file(self, filename, content, mode='w'):
with open(filename, mode) as file:
file.write(content)
self.addCleanup(os.unlink, filename)
def create_remote_file(self, vm, filename, content):
self.loop.run_until_complete(vm.run_for_stdio(
'cat > {}'.format(shlex.quote(filename)),
user='root', input=content.encode('utf-8')))
def test_000_start_shutdown(self):
# TODO: wait_for, timeout
self.loop.run_until_complete(self.testvm1.start())

مشاهده پرونده

@ -169,4 +169,4 @@ def load_tests(loader, tests, pattern):
'TC_40_PVGrub_' + template,
(TC_40_PVGrub, qubes.tests.QubesTestCase),
{'template': template})))
return tests
return tests