Пример #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']
Пример #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'
                ]
Пример #3
0
def test_get_open_files():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.get_open_files() == [['12345', 'foo'], ['67890', 'bar']]
Пример #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')
Пример #5
0
def test_cleanup_filter_non_egg():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert not cmd.filter_victim('foo')
Пример #6
0
def test_cleanup_filter_OK():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.filter_victim('foo.egg')
Пример #7
0
def test_egg_is_ignored_directory3():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('ANY-thing12.egg')
Пример #8
0
def test_svn_is_ignored_directory():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('.svn')
Пример #9
0
def test_is_ignored_directory_ok():
    t = clean.clean(Distribution())
    assert not t._is_ignored_directory('not and egg or svn')
Пример #10
0
def test_get_open_files():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.get_open_files() == [['12345', 'foo'], ['67890', 'bar']]
Пример #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')
Пример #12
0
def test_cleanup_filter_non_egg():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert not cmd.filter_victim('foo')
Пример #13
0
def test_cleanup_filter_OK():
    dist = Distribution()
    cmd = clean.clean(dist)
    assert cmd.filter_victim('foo.egg')
Пример #14
0
def test_egg_is_ignored_directory3():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('ANY-thing12.egg')
Пример #15
0
def test_svn_is_ignored_directory():
    t = clean.clean(Distribution())
    assert t._is_ignored_directory('.svn')
Пример #16
0
def test_is_ignored_directory_ok():
    t = clean.clean(Distribution())
    assert not t._is_ignored_directory('not and egg or svn')
Пример #17
0
 def setup(self):
     self.tidy = clean.clean(Distribution())
Пример #18
0
 def setup(self):
     self.tidy = clean.clean(Distribution())