提交 da1ddfdb 编写于 作者: L Lukáš Doktor

autopep8 style cleanup

Autopep8 style cleanup + alphabetic import + import cleanup in
avocado.core.{loader,test} and selftests.functional.test_basic.
Signed-off-by: NLukáš Doktor <ldoktor@redhat.com>
上级 0e7922b9
......@@ -17,28 +17,21 @@
Test loader module.
"""
import ast
import collections
import fnmatch
import imp
import inspect
import os
import re
import sys
import shlex
import fnmatch
import ast
import sys
from . import data_dir
from . import output
from . import test
from . import exceptions
from .settings import settings
from ..utils import path
from ..utils import stacktrace
try:
import cStringIO as StringIO
except ImportError:
import StringIO
from .settings import settings
DEFAULT = False # Show default tests (for execution)
......@@ -138,7 +131,7 @@ class TestLoaderProxy(object):
idx = loaders.index("@DEFAULT")
loaders = (loaders[:idx] + [plugin for plugin in supported_loaders
if plugin not in loaders] +
loaders[idx+1:])
loaders[idx + 1:])
while "@DEFAULT" in loaders: # Remove duplicite @DEFAULT entries
loaders.remove("@DEFAULT")
......@@ -567,7 +560,8 @@ class FileLoader(TestLoader):
for test_class, test_methods in tests.items():
if isinstance(test_class, str):
for test_method in test_methods:
name = test_name + ':%s.%s' % (test_class, test_method)
name = test_name + \
':%s.%s' % (test_class, test_method)
tst = (test_class, {'name': name,
'modulePath': test_path,
'methodName': test_method})
......
......@@ -10,8 +10,8 @@
#
# This code was inspired in the autotest project,
# client/shared/test.py
# Authors: Martin J Bligh <mbligh@google.com>, Andy Whitcroft <apw@shadowen.org>
import re
# Authors: Martin J Bligh <mbligh@google.com>,
# Andy Whitcroft <apw@shadowen.org>
"""
Contains the base test implementation, used as a base for the actual
......@@ -22,25 +22,27 @@ import inspect
import logging
import os
import pipes
import re
import shutil
import sys
import time
if sys.version_info[:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
from . import data_dir
from . import sysinfo
from . import exceptions
from . import multiplexer
from .version import VERSION
from . import sysinfo
from ..utils import data_structures
from ..utils import genio
from ..utils import path as utils_path
from ..utils import process
from ..utils import stacktrace
from ..utils import data_structures
from .version import VERSION
if sys.version_info[:2] == (2, 6):
import unittest2 as unittest
else:
import unittest
class Test(unittest.TestCase):
......@@ -410,12 +412,14 @@ class Test(unittest.TestCase):
try:
self.check_reference_stdout()
except Exception, details:
stacktrace.log_exc_info(sys.exc_info(), logger='avocado.test')
stacktrace.log_exc_info(sys.exc_info(),
logger='avocado.test')
stdout_check_exception = details
try:
self.check_reference_stderr()
except Exception, details:
stacktrace.log_exc_info(sys.exc_info(), logger='avocado.test')
stacktrace.log_exc_info(sys.exc_info(),
logger='avocado.test')
stderr_check_exception = details
elif not job_standalone:
if output_check_record in ['all', 'stdout']:
......
......@@ -245,7 +245,8 @@ class RunnerOperationTest(unittest.TestCase):
Tests that the `latest` link to the latest job results is created early
"""
os.chdir(basedir)
cmd_line = ('./scripts/avocado run --sysinfo=off --job-results-dir %s examples/tests/passtest.py' % self.tmpdir)
cmd_line = ('./scripts/avocado run --sysinfo=off --job-results-dir %s '
'examples/tests/passtest.py' % self.tmpdir)
avocado_process = process.SubProcess(cmd_line)
avocado_process.start()
link = os.path.join(self.tmpdir, 'latest')
......@@ -304,7 +305,8 @@ class RunnerHumanOutputTest(unittest.TestCase):
self.assertEqual(result.exit_status, expected_rc,
"Avocado did not return rc %d:\n%s" %
(expected_rc, result))
self.assertIn('skiponsetup.py:SkipOnSetupTest.test_wont_be_executed: SKIP', result.stdout)
self.assertIn('skiponsetup.py:SkipOnSetupTest.test_wont_be_executed:'
' SKIP', result.stdout)
def tearDown(self):
shutil.rmtree(self.tmpdir)
......@@ -319,15 +321,16 @@ class RunnerSimpleTest(unittest.TestCase):
PASS_SCRIPT_CONTENTS,
'avocado_simpletest_functional')
self.pass_script.save()
self.fail_script = script.TemporaryScript(
'avocado_fail.sh',
self.fail_script = script.TemporaryScript('avocado_fail.sh',
FAIL_SCRIPT_CONTENTS,
'avocado_simpletest_functional')
'avocado_simpletest_'
'functional')
self.fail_script.save()
def test_simpletest_pass(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --job-results-dir %s --sysinfo=off %s' % (self.tmpdir, self.pass_script.path)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off'
' %s' % (self.tmpdir, self.pass_script.path))
result = process.run(cmd_line, ignore_status=True)
expected_rc = 0
self.assertEqual(result.exit_status, expected_rc,
......@@ -336,7 +339,8 @@ class RunnerSimpleTest(unittest.TestCase):
def test_simpletest_fail(self):
os.chdir(basedir)
cmd_line = './scripts/avocado run --job-results-dir %s --sysinfo=off %s' % (self.tmpdir, self.fail_script.path)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off'
' %s' % (self.tmpdir, self.fail_script.path))
result = process.run(cmd_line, ignore_status=True)
expected_rc = 1
self.assertEqual(result.exit_status, expected_rc,
......@@ -353,7 +357,8 @@ class RunnerSimpleTest(unittest.TestCase):
"""
os.chdir(basedir)
one_hundred = 'failtest ' * 100
cmd_line = './scripts/avocado run --job-results-dir %s --sysinfo=off %s' % (self.tmpdir, one_hundred)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off'
' %s' % (self.tmpdir, one_hundred))
initial_time = time.time()
result = process.run(cmd_line, ignore_status=True)
actual_time = time.time() - initial_time
......@@ -369,7 +374,8 @@ class RunnerSimpleTest(unittest.TestCase):
"""
os.chdir(basedir)
sleep_fail_sleep = 'sleeptest ' + 'failtest ' * 100 + 'sleeptest'
cmd_line = './scripts/avocado run --job-results-dir %s --sysinfo=off %s' % (self.tmpdir, sleep_fail_sleep)
cmd_line = './scripts/avocado run --job-results-dir %s --sysinfo=off %s' % (
self.tmpdir, sleep_fail_sleep)
initial_time = time.time()
result = process.run(cmd_line, ignore_status=True)
actual_time = time.time() - initial_time
......@@ -602,7 +608,8 @@ class PluginsXunitTest(AbsPluginsTest, unittest.TestCase):
def run_and_check(self, testname, e_rc, e_ntests, e_nerrors,
e_nnotfound, e_nfailures, e_nskip):
os.chdir(basedir)
cmd_line = './scripts/avocado run --job-results-dir %s --sysinfo=off --xunit - %s' % (self.tmpdir, testname)
cmd_line = ('./scripts/avocado run --job-results-dir %s --sysinfo=off'
' --xunit - %s' % (self.tmpdir, testname))
result = process.run(cmd_line, ignore_status=True)
xml_output = result.stdout
self.assertEqual(result.exit_status, e_rc,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册