Esempio n. 1
0
def test_find_victims():
    my_working_set = [
       Pkg('acme.foo', [], location='site-packages/acme.foo.egg'),
       Pkg('acme.bar', [], location='site-packages/acme.bar.egg'),
    ]

    def get_site_packages():
        return ['site-packages/acme.foo.egg',
                'site-packages/acme.bar.egg',
                'site-packages/acme.baz.egg',
                'site-packages/acme.qux.egg',
                'site-packages/acme.spam.pth']

    with patch.object(clean, 'working_set', my_working_set):
        with patch.object(sys, 'exec_prefix', 'site-packages'):
            dist = Distribution()
            cmd = clean.clean(dist)
            cmd.get_site_packages = lambda: ""
            with patch("os.listdir", return_value=get_site_packages()):
                assert cmd.find_victims() == ['site-packages/acme.baz.egg',
                                              'site-packages/acme.qux.egg']
Esempio n. 2
0
def test_find_victims():
    my_working_set = [
        Pkg('acme.foo', [], location='site-packages/acme.foo.egg'),
        Pkg('acme.bar', [], location='site-packages/acme.bar.egg'),
    ]

    def get_site_packages():
        return [
            'site-packages/acme.foo.egg', 'site-packages/acme.bar.egg',
            'site-packages/acme.baz.egg', 'site-packages/acme.qux.egg',
            'site-packages/acme.spam.pth'
        ]

    with patch.object(clean, 'working_set', my_working_set):
        with patch.object(sys, 'exec_prefix', 'site-packages'):
            dist = Distribution()
            cmd = clean.clean(dist)
            cmd.get_site_packages = lambda: ""
            with patch("os.listdir", return_value=get_site_packages()):
                assert cmd.find_victims() == [
                    'site-packages/acme.baz.egg', 'site-packages/acme.qux.egg'
                ]
Esempio n. 3
0
def test_get_open_files():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.get_open_files() == [['12345', 'foo'], ['67890', 'bar']]
Esempio n. 4
0
def test_cleanup_filter_open_file():
    dist = Distribution()
    cmd = clean.clean(dist)
    cmd.open_files = [('1234', '/path/to/foo.egg')]
    assert not cmd.filter_open_files('foo.egg')
Esempio n. 5
0
def test_cleanup_filter_non_egg():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert not cmd.filter_victim('foo')
Esempio n. 6
0
def test_cleanup_filter_OK():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.filter_victim('foo.egg')
Esempio n. 7
0
def test_egg_is_ignored_directory3():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('ANY-thing12.egg')
Esempio n. 8
0
def test_svn_is_ignored_directory():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('.svn')
Esempio n. 9
0
def test_is_ignored_directory_ok():
    t = clean.clean(Distribution())
    assert not t._is_ignored_directory('not and egg or svn')
Esempio n. 10
0
def test_get_open_files():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.get_open_files() == [['12345', 'foo'], ['67890', 'bar']]
Esempio n. 11
0
def test_cleanup_filter_open_file():
    dist = Distribution()
    cmd = clean.clean(dist)
    cmd.open_files = [('1234', '/path/to/foo.egg')]
    assert not cmd.filter_open_files('foo.egg')
Esempio n. 12
0
def test_cleanup_filter_non_egg():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert not cmd.filter_victim('foo')
Esempio n. 13
0
def test_cleanup_filter_OK():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.filter_victim('foo.egg')
Esempio n. 14
0
def test_egg_is_ignored_directory3():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('ANY-thing12.egg')
Esempio n. 15
0
def test_svn_is_ignored_directory():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('.svn')
Esempio n. 16
0
def test_is_ignored_directory_ok():
    t = clean.clean(Distribution())
    assert not t._is_ignored_directory('not and egg or svn')
Esempio n. 17
0
 def setup(self):
     self.tidy = clean.clean(Distribution())
Esempio n. 18
0
 def setup(self):
     self.tidy = clean.clean(Distribution())