def test_add_from_site_is_ignored(self):
     location = '/test/location/does-not-have-to-exist'
     # PthDistributions expects all locations to be normalized
     location = pkg_resources.normalize_path(location)
     pth = PthDistributions('does-not_exist', [location, ])
     assert not pth.dirty
     pth.add(PRDistribution(location))
     assert not pth.dirty
Пример #2
0
 def test_add_from_cwd_site_sets_dirty(self):
     '''a pth file manager should set dirty
     if a distribution is in site but also the cwd
     '''
     pth = PthDistributions('does-not_exist', [os.getcwd()])
     assert not pth.dirty
     pth.add(PRDistribution(os.getcwd()))
     assert pth.dirty
 def test_add_from_cwd_site_sets_dirty(self):
     '''a pth file manager should set dirty
     if a distribution is in site but also the cwd
     '''
     pth = PthDistributions('does-not_exist', [os.getcwd()])
     self.assertTrue(not pth.dirty)
     pth.add(PRDistribution(os.getcwd()))
     self.assertTrue(pth.dirty)
Пример #4
0
 def test_add_from_cwd_site_sets_dirty(self):
     """a pth file manager should set dirty
     if a distribution is in site but also the cwd
     """
     pth = PthDistributions("does-not_exist", [os.getcwd()])
     self.assert_(not pth.dirty)
     pth.add(PRDistribution(os.getcwd()))
     self.assert_(pth.dirty)
Пример #5
0
 def test_add_from_site_is_ignored(self):
     location = '/test/location/does-not-have-to-exist'
     # PthDistributions expects all locations to be normalized
     location = pkg_resources.normalize_path(location)
     pth = PthDistributions('does-not_exist', [location, ])
     assert not pth.dirty
     pth.add(PRDistribution(location))
     assert not pth.dirty
 def test_add_from_site_is_ignored(self):
     if os.name != 'nt':
         location = '/test/location/does-not-have-to-exist'
     else:
         location = 'c:\\does_not_exist'
     pth = PthDistributions('does-not_exist', [location, ])
     self.assertTrue(not pth.dirty)
     pth.add(PRDistribution(location))
     self.assertTrue(not pth.dirty)
Пример #7
0
 def test_add_from_site_is_ignored(self):
     if os.name != "nt":
         location = "/test/location/does-not-have-to-exist"
     else:
         location = "c:\\does_not_exist"
     pth = PthDistributions("does-not_exist", [location])
     self.assert_(not pth.dirty)
     pth.add(PRDistribution(location))
     self.assert_(not pth.dirty)
Пример #8
0
 def test_add_from_site_is_ignored(self):
     if os.name != 'nt':
         location = '/test/location/does-not-have-to-exist'
     else:
         location = 'c:\\does_not_exist'
     pth = PthDistributions('does-not_exist', [location, ])
     self.assert_(not pth.dirty)
     pth.add(PRDistribution(location))
     self.assert_(not pth.dirty)
Пример #9
0
def assert_dists_in_pth(mocks, *dists):

    # Check that only the required distributions were added to "*.pth" file
    pth_file = [f for n, f in
                mocks[_easy_install_mocks][_written_pth_files].items()
                if os.path.basename(n) == "easy-install.pth"]

    pth_file = pth_file[0] if pth_file else io.BytesIO()

    dists = list(dists)

    pth_filename = "/<pth_file>"
    base_d = normalize_path(os.path.dirname(pth_filename))

    def find_distributions(path_item, only=False):  # @UnusedVariable
        d = [d for d in dists
             if normalize_path(os.path.join(base_d, d.location)) == path_item]
        assert len(d) == 1, ("Distribution on path [%s] should not have "
                             "been added to '.pth' file" % str(path_item))
        dists.remove(d[0])
        return []

    pth_file_dict = {pth_filename: pth_file}
    pth_file.seek(0)

    with ExitStack() as stack:
        ec = stack.enter_context
        ec(_patch_open(pth_file_dict))
        ec(patch("os.path.exists", new=lambda _: True))
        ec(patch("os.path.isfile", new=lambda f: f == pth_filename))
        ec(patch(_ei_find_distributions, new=find_distributions))

        PthDistributions(pth_filename)

    assert not dists, ("[%d] distributions were not added to the '.pth' "
                       "file: %s" % (len(dists), str(dists)))
Пример #10
0
#!@PYTHON@

import sys

from setuptools.command.easy_install import PthDistributions
from pkg_resources import find_distributions

usage = "@PYPREFIX@-manage-eggs [ register | unregister ] egg\n"

if len(sys.argv) != 3 or sys.argv[1] not in ("register", "unregister"):
	sys.stderr.write(usage)
	sys.exit(1)

pth = PthDistributions("@PYSITELIB@/easy-install.pth")
distrib = find_distributions(sys.argv[2], True).next()
if sys.argv[1] == "register":
	pth.add(distrib)
elif sys.argv[1] == "unregister":
	pth.remove(distrib)
pth.save()
Пример #11
0
 def test_add_from_site_is_ignored(self):
     pth = PthDistributions('does-not_exist',
                            ['/test/location/does-not-have-to-exist'])
     self.assert_(not pth.dirty)
     pth.add(PRDistribution('/test/location/does-not-have-to-exist'))
     self.assert_(not pth.dirty)
Пример #12
0
 def test_add_from_site_is_ignored(self):
     pth = PthDistributions('does-not_exist', ['/test/location/does-not-have-to-exist'])
     self.assert_(not pth.dirty)
     pth.add(PRDistribution('/test/location/does-not-have-to-exist'))
     self.assert_(not pth.dirty)
Пример #13
0
#!@PYTHON@

import sys

from setuptools.command.easy_install import PthDistributions
from pkg_resources import find_distributions

usage = "@PYPREFIX@-manage-eggs [ register | unregister ] egg\n"

if len(sys.argv) != 3 or sys.argv[1] not in ("register", "unregister"):
    sys.stderr.write(usage)
    sys.exit(1)

pth = PthDistributions("@PYSITELIB@/easy-install.pth")
distrib = find_distributions(sys.argv[2], True).next()
if sys.argv[1] == "register":
    pth.add(distrib)
elif sys.argv[1] == "unregister":
    pth.remove(distrib)
pth.save()