Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/setuptools/tests/test_test.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
| author | bcclaywell |
|---|---|
| date | Mon, 12 Oct 2015 17:43:33 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d67268158946 |
|---|---|
| 1 # -*- coding: UTF-8 -*- | |
| 2 | |
| 3 from __future__ import unicode_literals | |
| 4 | |
| 5 import os | |
| 6 import site | |
| 7 | |
| 8 import pytest | |
| 9 | |
| 10 from setuptools.command.test import test | |
| 11 from setuptools.dist import Distribution | |
| 12 | |
| 13 from .textwrap import DALS | |
| 14 from . import contexts | |
| 15 | |
| 16 SETUP_PY = DALS(""" | |
| 17 from setuptools import setup | |
| 18 | |
| 19 setup(name='foo', | |
| 20 packages=['name', 'name.space', 'name.space.tests'], | |
| 21 namespace_packages=['name'], | |
| 22 test_suite='name.space.tests.test_suite', | |
| 23 ) | |
| 24 """) | |
| 25 | |
| 26 NS_INIT = DALS(""" | |
| 27 # -*- coding: Latin-1 -*- | |
| 28 # Söme Arbiträry Ünicode to test Distribute Issüé 310 | |
| 29 try: | |
| 30 __import__('pkg_resources').declare_namespace(__name__) | |
| 31 except ImportError: | |
| 32 from pkgutil import extend_path | |
| 33 __path__ = extend_path(__path__, __name__) | |
| 34 """) | |
| 35 | |
| 36 TEST_PY = DALS(""" | |
| 37 import unittest | |
| 38 | |
| 39 class TestTest(unittest.TestCase): | |
| 40 def test_test(self): | |
| 41 print "Foo" # Should fail under Python 3 unless 2to3 is used | |
| 42 | |
| 43 test_suite = unittest.makeSuite(TestTest) | |
| 44 """) | |
| 45 | |
| 46 | |
| 47 @pytest.fixture | |
| 48 def sample_test(tmpdir_cwd): | |
| 49 os.makedirs('name/space/tests') | |
| 50 | |
| 51 # setup.py | |
| 52 with open('setup.py', 'wt') as f: | |
| 53 f.write(SETUP_PY) | |
| 54 | |
| 55 # name/__init__.py | |
| 56 with open('name/__init__.py', 'wb') as f: | |
| 57 f.write(NS_INIT.encode('Latin-1')) | |
| 58 | |
| 59 # name/space/__init__.py | |
| 60 with open('name/space/__init__.py', 'wt') as f: | |
| 61 f.write('#empty\n') | |
| 62 | |
| 63 # name/space/tests/__init__.py | |
| 64 with open('name/space/tests/__init__.py', 'wt') as f: | |
| 65 f.write(TEST_PY) | |
| 66 | |
| 67 | |
| 68 @pytest.mark.skipif('hasattr(sys, "real_prefix")') | |
| 69 @pytest.mark.usefixtures('user_override') | |
| 70 @pytest.mark.usefixtures('sample_test') | |
| 71 class TestTestTest: | |
| 72 | |
| 73 def test_test(self): | |
| 74 params = dict( | |
| 75 name='foo', | |
| 76 packages=['name', 'name.space', 'name.space.tests'], | |
| 77 namespace_packages=['name'], | |
| 78 test_suite='name.space.tests.test_suite', | |
| 79 use_2to3=True, | |
| 80 ) | |
| 81 dist = Distribution(params) | |
| 82 dist.script_name = 'setup.py' | |
| 83 cmd = test(dist) | |
| 84 cmd.user = 1 | |
| 85 cmd.ensure_finalized() | |
| 86 cmd.install_dir = site.USER_SITE | |
| 87 cmd.user = 1 | |
| 88 with contexts.quiet(): | |
| 89 # The test runner calls sys.exit | |
| 90 with contexts.suppress_exceptions(SystemExit): | |
| 91 cmd.run() |
