Пример #1
0
def test_copy_file():
    with patch.object(path.path, 'getcwd', CWD):
        with patch.object(path.path, 'copyfile', Mock(spec=path.path.copyfile)) as copy_mock:
            dist = Distribution({'name': 'acme.foo'})
            cmd = test_egg.test_egg(dist)
            src = Mock()
            dest = Mock()

            cmd._copy_file(src, dest)

            dest.parent.makedirs_p.assert_called_once_with()
            copy_mock.assert_called_once_with(src, dest)
Пример #2
0
def test_copy_file():
    with ExitStack() as stack:
        stack.enter_context(patched_cwd())
        makedirs_mock = stack.enter_context(patch("os.makedirs"))
        stack.enter_context(patch("os.path.exists", return_value=False))
        copy_mock = stack.enter_context(patch("shutil.copyfile"))

        dist = Distribution({'name': 'acme.foo'})
        cmd = test_egg.test_egg(dist)
        src = "<src>"
        dest = "<dest>"

        cmd._copy_file(src, dest)

        makedirs_mock.assert_called_once_with(CWD.return_value)
        copy_mock.assert_called_once_with(src, dest)
Пример #3
0
def _test_init_files(exists):
    with patched_cwd():
        dist = Distribution({'name': 'acme.foo'})
        cmd = test_egg.test_egg(dist)

        top_dirs = ['sub', '.svn', '__pycache__']
        walk_dirs = [("top", top_dirs, []), ("sub", [], [])]
        os_walk_mock = Mock(return_value=walk_dirs)

        with ExitStack() as stack:
            stack.enter_context(patch("os.path.isdir", return_value=True))
            stack.enter_context(patch("os.walk", new=os_walk_mock))
            stack.enter_context(patch("os.path.isfile", return_value=exists))
            files_written = stack.enter_context(_patch_open())

            cmd.create_init_files("top")

        assert top_dirs == ["sub"]

        return files_written
Пример #4
0
def _test_init_files(exists):
    with patch.object(path.path, 'getcwd', CWD):
        dist = Distribution({'name': 'acme.foo'})
        cmd = test_egg.test_egg(dist)

        top_dir = MagicMock()
        top_init_file = Mock()
        top_init_file.isfile.return_value = exists

        sub_init_file = Mock()
        sub_init_file.isfile.return_value = exists

        sub_dir = MagicMock()
        sub_dir.__div__.return_value = sub_init_file

        top_dir.walkdirs.return_value = [sub_dir, '.svn', '__pycache__']
        top_dir.__div__.return_value = top_init_file

        cmd.create_init_files(top_dir)
        return top_init_file, sub_init_file
Пример #5
0
def get_cmd():
    return test_egg.test_egg(Distribution({'name': 'acme.foo',
                                           'tests_require': ['bar', 'baz'],
                                           'namespace_packages': ['acme'],
                                           'packages': ['acme.foo']}))
Пример #6
0
def get_cmd():
    return test_egg.test_egg(Distribution({'name': 'acme.foo',
                                           'tests_require': ['bar', 'baz'],
                                           'namespace_packages': ['acme'],
                                           'packages': ['acme.foo']}))