Commits

Daniel Holth  committed 30739ff

improve tests

  • Participants
  • Parent commits 8d9d6f7

Comments (0)

Files changed (3)

 [pytest]
-cov=wheel
-addopts=--ignore=dist --ignore=build
+addopts=--ignore=dist --ignore=build --cov=wheel
 
 [metadata]
 provides-extra = 

File wheel/test/complex-dist/setup.py

     def u8(s):
         return s
 
-if __name__ == "__main__":
-    setup(name='complex-dist',
-          version='0.1',
-          description=u8('Another testing distribution \N{SNOWMAN}'),
-          author="Illustrious Author",
-          author_email="illustrious@example.org",
-          url="http://example.org/exemplary",
-          packages=['complexdist'],
-          setup_requires=["wheel", "setuptools"],
-          install_requires=["quux", "splort"],
-          extras_require={'simple':['simple.dist']},
-          tests_require=["foo", "bar"],
-          entry_points={'console_scripts':['complex-dist=complexdist:main']}
-          )
+setup(name='complex-dist',
+      version='0.1',
+      description=u8('Another testing distribution \N{SNOWMAN}'),
+      author="Illustrious Author",
+      author_email="illustrious@example.org",
+      url="http://example.org/exemplary",
+      packages=['complexdist'],
+      setup_requires=["wheel", "setuptools"],
+      install_requires=["quux", "splort"],
+      extras_require={'simple':['simple.dist']},
+      tests_require=["foo", "bar"],
+      entry_points={'console_scripts':['complex-dist=complexdist:main']}
+      )
 

File wheel/test/test_basic.py

 from pkg_resources import resource_filename
 
 import wheel.util
+import wheel.tool
+
 from wheel import egg2wheel
 from wheel.install import WheelFile
 from zipfile import ZipFile
 from shutil import rmtree
 
-test_distributions = ("simple.dist", "complex-dist", "headers.dist")
+test_distributions = ("complex-dist", "simple.dist", "headers.dist")
 
 def teardown_module():
     """Delete eggs/wheels created by tests."""
                 rmtree(os.path.join(base, dist, subdir))
             except OSError:
                 pass
-                        
+
+def setup_module():
+    build_wheel()
+    build_egg()
+
+def build_wheel():
+    """Build wheels from test distributions."""
+    for dist in test_distributions:
+        pwd = os.path.abspath(os.curdir)
+        distdir = pkg_resources.resource_filename('wheel.test', dist)
+        os.chdir(distdir)
+        try:
+            sys.argv = ['', 'bdist_wheel']
+            exec(compile(open('setup.py').read(), 'setup.py', 'exec'))
+        finally:
+            os.chdir(pwd)
+
+def build_egg():
+    """Build eggs from test distributions."""
+    for dist in test_distributions:
+        pwd = os.path.abspath(os.curdir)
+        distdir = pkg_resources.resource_filename('wheel.test', dist)
+        os.chdir(distdir)
+        try:
+            sys.argv = ['', 'bdist_egg']
+            exec(compile(open('setup.py').read(), 'setup.py', 'exec'))
+        finally:
+            os.chdir(pwd)
+
 def test_findable():
     """Make sure pkg_resources can find us."""
     assert pkg_resources.working_set.by_key['wheel'].version
 
-
 def test_egg_re():
     """Make sure egg_info_re matches."""
     egg_names = open(pkg_resources.resource_filename('wheel', 'eggnames.txt'))
             continue
         assert egg2wheel.egg_info_re.match(line), line
 
- 
 def test_compatibility_tags():
     """Test compatibilty tags are working."""
     wf = WheelFile("package-1.0.0-cp32.cp33-noabi-noarch.whl")
     wf2_info = wf2.parsed_filename.groupdict()
     assert wf2_info['build'] == '1st', wf2_info
 
+def test_convert_egg():
+    base = pkg_resources.resource_filename('wheel.test', '')
+    for dist in test_distributions:
+        distdir = os.path.join(base, dist, 'dist')
+        eggs = [e for e in os.listdir(distdir) if e.endswith('.egg')]
+        wheel.tool.convert(eggs, distdir, verbose=False)
 
-def test_bdist_wheel():
-    """Make sure bdist_wheel finish without errors."""
+def test_unpack():
+    """
+    Make sure 'wheel unpack' works.
+    This also verifies the integrity of our testing wheel files.
+    """
     for dist in test_distributions:
-        pwd = os.curdir
-        simpledist = pkg_resources.resource_filename('wheel.test', dist)
-        os.chdir(simpledist)    
-        try:
-            sys.argv = ['', 'bdist_wheel']
-            exec(compile(open('setup.py').read(), 'setup.py', 'exec'))
-        finally:
-            os.chdir(pwd)
-            
-def test_convert_egg():
-    """Convert some eggs to wheels."""
-    for dist in ("simple.dist", "complex-dist", "headers.dist"):
-        pwd = os.curdir
-        simpledist = pkg_resources.resource_filename('wheel.test', dist)
-        os.chdir(simpledist)
-        try:
-            sys.argv = ['', 'bdist_egg']
-            exec(compile(open('setup.py').read(), 'setup.py', 'exec'))
-        finally:
-            os.chdir(pwd)
+        distdir = pkg_resources.resource_filename('wheel.test', 
+                                                  os.path.join(dist, 'dist'))
+        for wheelfile in (w for w in os.listdir(distdir) if w.endswith('.whl')):
+            wheel.tool.unpack(os.path.join(distdir, wheelfile), distdir)
 
 def test_pymeta():
     """Make sure pymeta.json exists and validates against our schema."""
     # XXX this test may need manual cleanup of older wheels
-    
+
     import jsonschema
-    
+
     def open_json(filename):
         return json.loads(open(filename, 'rb').read().decode('utf-8'))
-    
+
     pymeta_schema = open_json(resource_filename('wheel.test',
                                                 'pymeta-schema.json'))
     valid = 0
             wheel.context = context
         best = max(cand_wheels)
         assert list(best.tags)[0] == supp[0]
-        
+
         # assert_equal(
         #     list(map(get_tags, pick_best(cand_wheels, supp, top=False))), supp)