Commits

Ned Batchelder committed 6c396ba

Get rid of import craziness in the tests.

Comments (0)

Files changed (22)

 # Messages that may be silly:
 #   R0201: 42:Tracer.stop: Method could be a function
 #   C0321: 80:CodeUnit.__lt__: More than one statement on a single line    
-#   R0401:  1: Cyclic import (coverage -> coverage.control -> coverage.html)
-#   W0403:  4: Relative import 'coveragetest'
 #   E1103: 26:RunTests.test_run_python_file: Instance of 'file' has no 'getvalue' member (but some types could not be inferred)
-    R0201,C0321,R0401,W0403,E1103,
+    R0201,C0321,E1103,
 # Messages that are noisy for now, eventually maybe we'll turn them on:
 #   C0103:256:coverage.morf_filename: Invalid name "f" (should match [a-z_][a-z0-9_]{2,30}$)
 #   W0212: 86:Reporter.report_files: Access to a protected member _analyze of a client class     
-#   W0404: 22:run_tests_with_coverage: Reimport 'coverage' (imported line 18)
-    C0103,W0212,W0404
+    C0103,W0212
 
 [REPORTS]
 
 function-rgx=[a-z_][a-z0-9_]{2,30}$
 
 # Regular expression which should only match correct method names
-method-rgx=[a-z_][a-z0-9_]{2,30}$
+method-rgx=[a-z_][a-z0-9_]{2,30}$|setUp|tearDown|test_.*
 
 # Regular expression which should only match correct instance attribute names
 attr-rgx=[a-z_][a-z0-9_]{2,30}$

test/coveragetest.py

 from coverage.backward import sorted, StringIO      # pylint: disable=W0622
 from coverage.backward import to_bytes
 from coverage.control import _TEST_NAME_FILE
-from backtest import run_command
-from backunittest import TestCase
+from test.backtest import run_command
+from test.backunittest import TestCase
 
 class Tee(object):
     """A file-like that writes to all the file-likes it has."""
 import coverage
 from coverage.backward import StringIO
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 
 class SingletonApiTest(CoverageTest):

test/test_arcs.py

 """Tests for Coverage.py's arc measurement."""
 
-import os, sys
-
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+import sys
+from test.coveragetest import CoverageTest
 
 
 class SimpleArcTest(CoverageTest):

test/test_cmdline.py

 """Test cmdline.py for coverage."""
 
-import os, pprint, re, shlex, sys, textwrap
+import pprint, re, shlex, sys, textwrap
 import mock
 import coverage
 import coverage.cmdline
 from coverage.misc import ExceptionDuringRun
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest, OK, ERR
+from test.coveragetest import CoverageTest, OK, ERR
 
 
 class CmdLineTest(CoverageTest):

test/test_codeunit.py

 from coverage.codeunit import code_unit_factory
 from coverage.files import FileLocator
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 # pylint: disable=F0401
 # Unable to import 'aa' (No module named aa)

test/test_config.py

 # -*- coding: utf-8 -*-
 """Test the config file handling for coverage.py"""
 
-import os, sys
+import sys
 import coverage
 from coverage.misc import CoverageException
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 
 class ConfigTest(CoverageTest):

test/test_coverage.py

 """Tests for Coverage."""
 # http://nedbatchelder.com/code/coverage
 
-import os, sys
-
+import sys
 import coverage
 from coverage.misc import CoverageException
-
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 
 class TestCoverageTest(CoverageTest):

test/test_data.py

 """Tests for coverage.data"""
 
-import os, sys
-
 from coverage.backward import pickle
 from coverage.data import CoverageData
 from coverage.files import PathAliases
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 
 DATA_1 = { 'a.py': {1:None, 2:None}, 'b.py': {3:None} }

test/test_execfile.py

 from coverage.execfile import run_python_file, run_python_module
 from coverage.misc import NoSource
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 here = os.path.dirname(__file__)
 

test/test_farm.py

 import difflib, filecmp, fnmatch, glob, os, re, shutil, sys
 from nose.plugins.skip import SkipTest
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from backtest import run_command, execfile          # pylint: disable=W0622
+from test.backtest import run_command, execfile      # pylint: disable=W0622
 
 from coverage.control import _TEST_NAME_FILE
 

test/test_files.py

 """Tests for files.py"""
 
-import os, sys
+import os
 
 from coverage.files import FileLocator, TreeMatcher, FnmatchMatcher
 from coverage.files import PathAliases, find_python_files, abs_file
 from coverage.backward import set                   # pylint: disable=W0622
 from coverage.misc import CoverageException
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 
 class FileLocatorTest(CoverageTest):

test/test_html.py

 import coverage
 from coverage.misc import NotPython, NoSource
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 class HtmlTestHelpers(CoverageTest):
     """Methods that help with HTML tests."""

test/test_misc.py

 """Tests of miscellaneous stuff."""
 
-import os, sys
-
 from coverage.misc import Hasher, file_be_gone
 from coverage import __version__, __url__
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 class HasherTest(CoverageTest):
     """Test our wrapper of md5 hashing."""

test/test_oddball.py

 import os, sys
 import coverage
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
-import osinfo
+from test.coveragetest import CoverageTest
+from test import osinfo
 
 class ThreadingTest(CoverageTest):
     """Tests of the threading support."""

test/test_parser.py

 """Tests for Coverage.py's code parsing."""
 
-import os, sys, textwrap
-
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
-
+import textwrap
+from test.coveragetest import CoverageTest
 from coverage.parser import CodeParser
 
 

test/test_phystokens.py

 """Tests for Coverage.py's improved tokenizer."""
 
-import os, re, sys
-
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
-
+import os, re
+from test.coveragetest import CoverageTest
 from coverage.phystokens import source_token_lines
 
 

test/test_process.py

 from nose.plugins.skip import SkipTest
 import coverage
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 here = os.path.dirname(__file__)
 

test/test_results.py

 """Tests for Coverage.py's results analysis."""
 
-import os, sys
-
 from coverage.results import Numbers
-
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 
 class NumbersTest(CoverageTest):

test/test_summary.py

 import coverage
 from coverage.backward import StringIO
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 class SummaryTest(CoverageTest):
     """Tests of the text summary reporting for coverage.py."""

test/test_testing.py

 """Tests that our test infrastructure is really working!"""
 
 import os, sys
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
 from coverage.backward import to_bytes, rpartition
-from backunittest import TestCase
-from coveragetest import CoverageTest
+from test.backunittest import TestCase
+from test.coveragetest import CoverageTest
 
 from coverage.backward import set                   # pylint: disable=W0622
 
 """Tests for XML reports from coverage.py."""
 
-import os, re, sys
+import os, re
 import coverage
 
-sys.path.insert(0, os.path.split(__file__)[0]) # Force relative import for Py3k
-from coveragetest import CoverageTest
+from test.coveragetest import CoverageTest
 
 class XmlReportTest(CoverageTest):
     """Tests of the XML reports from coverage.py."""