diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-06-22 19:31:15 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-06-22 19:31:15 +0000 |
| commit | 2db4e6855ef82c18e95bdf4c0b8af52269624c0a (patch) | |
| tree | 4c138c4401ee9fc9460d8297d078671a0e11c3e7 | |
| parent | dd331aa9fa43bbb02d8aa4ff63622d23b8aed1dd (diff) | |
| parent | c986a17be967fee897897cb8abc86b27d2426f75 (diff) | |
| download | oslo-2db4e6855ef82c18e95bdf4c0b8af52269624c0a.tar.gz oslo-2db4e6855ef82c18e95bdf4c0b8af52269624c0a.tar.xz oslo-2db4e6855ef82c18e95bdf4c0b8af52269624c0a.zip | |
Merge "Skip argparse when injecting requirements."
| -rw-r--r-- | openstack/common/setup.py | 5 | ||||
| -rw-r--r-- | tests/unit/test_setup.py | 56 |
2 files changed, 53 insertions, 8 deletions
diff --git a/openstack/common/setup.py b/openstack/common/setup.py index 429ba35..6b34417 100644 --- a/openstack/common/setup.py +++ b/openstack/common/setup.py @@ -22,6 +22,7 @@ Utilities with minimum-depends for use in setup.py import os import re import subprocess +import sys from setuptools.command import sdist @@ -76,6 +77,10 @@ def parse_requirements(requirements_files=['requirements.txt', # -f lines are for index locations, and don't get used here elif re.match(r'\s*-f\s+', line): pass + # argparse is part of the standard library starting with 2.7 + # adding it to the requirements list screws distro installs + elif line == 'argparse' and sys.version_info >= (2, 7): + pass else: requirements.append(line) diff --git a/tests/unit/test_setup.py b/tests/unit/test_setup.py index 0ea0800..660388c 100644 --- a/tests/unit/test_setup.py +++ b/tests/unit/test_setup.py @@ -18,15 +18,12 @@ import os import unittest from tempfile import mkstemp +import sys -from openstack.common.setup import canonicalize_emails -from openstack.common.setup import parse_mailmap +from openstack.common.setup import * -class SetupTest(unittest.TestCase): - - def setUp(self): - (fd, self.mailmap) = mkstemp(prefix='openstack', suffix='.mailmap') +class EmailTestCase(unittest.TestCase): def test_str_dict_replace(self): string = 'Johnnie T. Hozer' @@ -34,6 +31,16 @@ class SetupTest(unittest.TestCase): self.assertEqual('Johnnie The Hozer', canonicalize_emails(string, mapping)) + +class MailmapTestCase(unittest.TestCase): + + def setUp(self): + (fd, self.mailmap) = mkstemp(prefix='openstack', suffix='.setup') + + def tearDown(self): + if os.path.exists(self.mailmap): + os.remove(self.mailmap) + def test_mailmap_with_fullname(self): with open(self.mailmap, 'w') as mm_fh: mm_fh.write("Foo Bar <email@foo.com> Foo Bar <email@bar.com>\n") @@ -52,6 +59,39 @@ class SetupTest(unittest.TestCase): self.assertEqual({'<email@bar.com>': '<email@foo.com>'}, parse_mailmap(self.mailmap)) + +class ParseRequirementsTest(unittest.TestCase): + + def setUp(self): + (fd, self.tmp_file) = mkstemp(prefix='openstack', suffix='.setup') + def tearDown(self): - if os.path.exists(self.mailmap): - os.remove(self.mailmap) + if os.path.exists(self.tmp_file): + os.remove(self.tmp_file) + + def test_parse_requirements_normal(self): + with open(self.tmp_file, 'w') as fh: + fh.write("foo\nbar") + self.assertEqual(['foo', 'bar'], + parse_requirements([self.tmp_file])) + + def test_parse_requirements_with_git_egg_url(self): + with open(self.tmp_file, 'w') as fh: + fh.write("-e git://foo.com/zipball#egg=bar") + self.assertEqual(['bar'], parse_requirements([self.tmp_file])) + + def test_parse_requirements_with_http_egg_url(self): + with open(self.tmp_file, 'w') as fh: + fh.write("https://foo.com/zipball#egg=bar") + self.assertEqual(['bar'], parse_requirements([self.tmp_file])) + + def test_parse_requirements_removes_index_lines(self): + with open(self.tmp_file, 'w') as fh: + fh.write("-f foobar") + self.assertEqual([], parse_requirements([self.tmp_file])) + + def test_parse_requirements_removes_argparse(self): + with open(self.tmp_file, 'w') as fh: + fh.write("argparse") + if sys.version_info >= (2, 7): + self.assertEqual([], parse_requirements([self.tmp_file])) |
