summaryrefslogtreecommitdiff
path: root/tests/test_codeunit.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_codeunit.py')
-rw-r--r--tests/test_codeunit.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/tests/test_codeunit.py b/tests/test_codeunit.py
index b3b188b4..66635092 100644
--- a/tests/test_codeunit.py
+++ b/tests/test_codeunit.py
@@ -3,8 +3,7 @@
import os
import sys
-from coverage.codeunit import code_unit_factory, code_units_factory
-from coverage.files import FileLocator
+from coverage.codeunit import CodeUnit, PythonCodeUnit, code_units_factory
from tests.coveragetest import CoverageTest
@@ -24,9 +23,9 @@ class CodeUnitTest(CoverageTest):
sys.path.append(testmods)
def test_filenames(self):
- acu = code_unit_factory("aa/afile.py", FileLocator())
- bcu = code_unit_factory("aa/bb/bfile.py", FileLocator())
- ccu = code_unit_factory("aa/bb/cc/cfile.py", FileLocator())
+ acu = PythonCodeUnit("aa/afile.py")
+ bcu = PythonCodeUnit("aa/bb/bfile.py")
+ ccu = PythonCodeUnit("aa/bb/cc/cfile.py")
self.assertEqual(acu.name, "aa/afile")
self.assertEqual(bcu.name, "aa/bb/bfile")
self.assertEqual(ccu.name, "aa/bb/cc/cfile")
@@ -38,9 +37,9 @@ class CodeUnitTest(CoverageTest):
self.assertEqual(ccu.source(), "# cfile.py\n")
def test_odd_filenames(self):
- acu = code_unit_factory("aa/afile.odd.py", FileLocator())
- bcu = code_unit_factory("aa/bb/bfile.odd.py", FileLocator())
- b2cu = code_unit_factory("aa/bb.odd/bfile.py", FileLocator())
+ acu = PythonCodeUnit("aa/afile.odd.py")
+ bcu = PythonCodeUnit("aa/bb/bfile.odd.py")
+ b2cu = PythonCodeUnit("aa/bb.odd/bfile.py")
self.assertEqual(acu.name, "aa/afile.odd")
self.assertEqual(bcu.name, "aa/bb/bfile.odd")
self.assertEqual(b2cu.name, "aa/bb.odd/bfile")
@@ -56,7 +55,7 @@ class CodeUnitTest(CoverageTest):
import aa.bb
import aa.bb.cc
- cu = code_units_factory([aa, aa.bb, aa.bb.cc], FileLocator())
+ cu = code_units_factory([aa, aa.bb, aa.bb.cc])
self.assertEqual(cu[0].name, "aa")
self.assertEqual(cu[1].name, "aa.bb")
self.assertEqual(cu[2].name, "aa.bb.cc")
@@ -72,10 +71,7 @@ class CodeUnitTest(CoverageTest):
import aa.bb.bfile
import aa.bb.cc.cfile
- cu = code_units_factory(
- [aa.afile, aa.bb.bfile, aa.bb.cc.cfile],
- FileLocator()
- )
+ cu = code_units_factory([aa.afile, aa.bb.bfile, aa.bb.cc.cfile])
self.assertEqual(cu[0].name, "aa.afile")
self.assertEqual(cu[1].name, "aa.bb.bfile")
self.assertEqual(cu[2].name, "aa.bb.cc.cfile")
@@ -87,10 +83,10 @@ class CodeUnitTest(CoverageTest):
self.assertEqual(cu[2].source(), "# cfile.py\n")
def test_comparison(self):
- acu = code_unit_factory("aa/afile.py", FileLocator())
- acu2 = code_unit_factory("aa/afile.py", FileLocator())
- zcu = code_unit_factory("aa/zfile.py", FileLocator())
- bcu = code_unit_factory("aa/bb/bfile.py", FileLocator())
+ acu = CodeUnit("aa/afile.py")
+ acu2 = CodeUnit("aa/afile.py")
+ zcu = CodeUnit("aa/zfile.py")
+ bcu = CodeUnit("aa/bb/bfile.py")
assert acu == acu2 and acu <= acu2 and acu >= acu2
assert acu < zcu and acu <= zcu and acu != zcu
assert zcu > acu and zcu >= acu and zcu != acu
@@ -108,6 +104,6 @@ class CodeUnitTest(CoverageTest):
# in the path is actually the .egg zip file.
self.assert_doesnt_exist(egg1.__file__)
- cu = code_units_factory([egg1, egg1.egg1], FileLocator())
+ cu = code_units_factory([egg1, egg1.egg1])
self.assertEqual(cu[0].source(), u"")
self.assertEqual(cu[1].source().split("\n")[0], u"# My egg file!")