コード例 #1
0
def create_project():
    project = Project("/")
    project.build_depends_on("testingframework")
    project.depends_on("sometool")
    project.depends_on(
        "pyassert", url="https://github.com/downloads/halimath/pyassert/pyassert-0.2.2.tar.gz")
    project.name = "Spam and Eggs"
    project.version = "1.2.3"
    project.summary = "This is a simple integration-test for distutils plugin."
    project.description = "As you might have guessed we have nothing to say here."
    project.authors = [
        Author("Udo Juettner", "*****@*****.**"), Author("Michael Gruber", "*****@*****.**")]
    project.license = "WTFPL"
    project.url = "http://github.com/pybuilder/pybuilder"

    def return_dummy_list():
        return ["spam", "eggs"]

    project.list_scripts = return_dummy_list
    project.list_packages = return_dummy_list
    project.list_modules = return_dummy_list

    project.set_property("distutils_classifiers", [
        "Development Status :: 5 - Beta", "Environment :: Console"])
    project.install_file("dir", "file1")
    project.install_file("dir", "file2")
    project.include_file("spam", "eggs")

    return project
コード例 #2
0
def create_project():
    project = Project("/")
    project.build_depends_on("testingframework")
    project.depends_on("sometool")
    project.depends_on(
        "pyassert",
        url=
        "https://github.com/downloads/halimath/pyassert/pyassert-0.2.2.tar.gz")
    project.name = "Spam and Eggs"
    project.version = "1.2.3"
    project.summary = "This is a simple integration-test for distutils plugin."
    project.description = "As you might have guessed we have nothing to say here."
    project.authors = [
        Author("Udo Juettner", "*****@*****.**"),
        Author("Michael Gruber", "*****@*****.**")
    ]
    project.license = "WTFPL"
    project.url = "http://github.com/pybuilder/pybuilder"
    project.explicit_namespaces = ["foo.bar", "quick.brown.fox"]

    def return_dummy_list():
        return ["spam", "eggs"]

    project.list_scripts = return_dummy_list
    project.list_packages = return_dummy_list
    project.list_modules = return_dummy_list

    project.set_property(
        "distutils_classifiers",
        ["Development Status :: 5 - Beta", "Environment :: Console"])
    project.install_file("dir", "file1")
    project.install_file("dir", "file2")
    project.include_file("spam", "eggs")

    return project
コード例 #3
0
ファイル: core_tests.py プロジェクト: 010110101001/pybuilder
class ProjectDataFilesTests(unittest.TestCase):

    def setUp(self):
        self.project = Project(basedir="/imaginary", name="Unittest")

    def test_should_return_empty_list_for_property_files_to_install(self):
        self.assertEquals([], self.project.files_to_install)

    def test_should_return_file_to_install(self):
        self.project.install_file("destination", "filename")

        self.assertEquals(
            [("destination", ["filename"])], self.project.files_to_install)

    def test_should_raise_exception_when_no_destination_given(self):
        self.assertRaises(
            ValueError, self.project.install_file, None, "Hello world.")

    def test_should_raise_exception_when_no_filename_given(self):
        self.assertRaises(
            ValueError, self.project.install_file, "destination", None)

    def test_should_raise_exception_when_filename_empty(self):
        self.assertRaises(
            ValueError, self.project.install_file, "destination", "\t   \n")

    def test_should_return_files_to_install_into_same_destination(self):
        self.project.install_file("destination", "filename1")
        self.project.install_file("destination", "filename2")

        self.assertEquals(
            [("destination", ["filename1", "filename2"])], self.project.files_to_install)

    def test_should_return_files_to_install_into_different_destinations(self):
        self.project.install_file("destination_a", "filename_a_1")
        self.project.install_file("destination_a", "filename_a_2")
        self.project.install_file("destination_b", "filename_b")

        self.assertEquals([("destination_a", ["filename_a_1", "filename_a_2"]),
                           ("destination_b", ["filename_b"])], self.project.files_to_install)

    def test_should_return_files_to_install_into_different_destinations_and_add_them_to_manifest(self):
        self.project.install_file("destination_a", "somepackage1/filename1")
        self.project.install_file("destination_a", "somepackage2/filename2")
        self.project.install_file("destination_b", "somepackage3/filename3")

        self.assertEquals(
            [("destination_a", ["somepackage1/filename1", "somepackage2/filename2"]),
             ("destination_b", ["somepackage3/filename3"])], self.project.files_to_install)
        self.assertEquals(
            ["somepackage1/filename1", "somepackage2/filename2", "somepackage3/filename3"], self.project.manifest_included_files)
コード例 #4
0
class BuildDataFilesStringTest(unittest.TestCase):
    def setUp(self):
        self.project = Project(".")

    def test_should_return_empty_data_files_string(self):
        self.assertEqual("[]", build_data_files_string(self.project))

    def test_should_return_data_files_string_including_several_files(self):
        self.project.install_file("bin", "activate")
        self.project.install_file("bin", "command-stub")
        self.project.install_file("bin", "rsync")
        self.project.install_file("bin", "ssh")

        self.assertEqual(
            "[\n            ('bin', ['activate', 'command-stub', 'rsync', 'ssh'])\n        ]",
            build_data_files_string(self.project))

    def test_should_return_data_files_string_with_files_to_be_installed_in_several_destinations(self):
        self.project.install_file("/usr/bin", "pyb")
        self.project.install_file("/etc", "pyb.cfg")
        self.project.install_file("data", "pyb.dat")
        self.project.install_file("data", "howto.txt")
        self.assertEqual("[\n            ('/usr/bin', ['pyb']),\n"
                         "            ('/etc', ['pyb.cfg']),\n"
                         "            ('data', ['pyb.dat', 'howto.txt'])\n"
                         "        ]",
                         build_data_files_string(self.project))
コード例 #5
0
class BuildDataFilesStringTest(unittest.TestCase):
    def setUp(self):
        self.project = Project(".")

    def test_should_return_empty_data_files_string(self):
        self.assertEqual("[]", build_data_files_string(self.project))

    def test_should_return_data_files_string_including_several_files(self):
        self.project.install_file("bin", "activate")
        self.project.install_file("bin", "command-stub")
        self.project.install_file("bin", "rsync")
        self.project.install_file("bin", "ssh")

        self.assertEqual(
            "[\n            ('bin', ['activate', 'command-stub', 'rsync', 'ssh'])\n        ]",
            build_data_files_string(self.project))

    def test_should_return_data_files_string_with_files_to_be_installed_in_several_destinations(
            self):
        self.project.install_file("/usr/bin", "pyb")
        self.project.install_file("/etc", "pyb.cfg")
        self.project.install_file("data", "pyb.dat")
        self.project.install_file("data", "howto.txt")
        self.assertEqual(
            "[\n            ('/usr/bin', ['pyb']),\n"
            "            ('/etc', ['pyb.cfg']),\n"
            "            ('data', ['pyb.dat', 'howto.txt'])\n"
            "        ]", build_data_files_string(self.project))
コード例 #6
0
class ProjectDataFilesTests(unittest.TestCase):
    def setUp(self):
        self.project = Project(basedir="/imaginary", name="Unittest")

    def test_should_return_empty_list_for_property_files_to_install(self):
        self.assertEqual([], self.project.files_to_install)

    def test_should_return_file_to_install(self):
        self.project.install_file("destination", "filename")

        self.assertEqual([("destination", ["filename"])],
                         self.project.files_to_install)

    def test_should_raise_exception_when_no_destination_given(self):
        self.assertRaises(ValueError, self.project.install_file, None,
                          "Hello world.")

    def test_should_raise_exception_when_no_filename_given(self):
        self.assertRaises(ValueError, self.project.install_file, "destination",
                          None)

    def test_should_raise_exception_when_filename_empty(self):
        self.assertRaises(ValueError, self.project.install_file, "destination",
                          "\t   \n")

    def test_should_return_files_to_install_into_same_destination(self):
        self.project.install_file("destination", "filename1")
        self.project.install_file("destination", "filename2")

        self.assertEqual([("destination", ["filename1", "filename2"])],
                         self.project.files_to_install)

    def test_should_return_files_to_install_into_different_destinations(self):
        self.project.install_file("destination_a", "filename_a_1")
        self.project.install_file("destination_a", "filename_a_2")
        self.project.install_file("destination_b", "filename_b")

        self.assertEqual([("destination_a", ["filename_a_1", "filename_a_2"]),
                          ("destination_b", ["filename_b"])],
                         self.project.files_to_install)

    def test_should_return_files_to_install_into_different_destinations_and_add_them_to_manifest(
            self):
        self.project.install_file("destination_a", "somepackage1/filename1")
        self.project.install_file("destination_a", "somepackage2/filename2")
        self.project.install_file("destination_b", "somepackage3/filename3")

        self.assertEqual([("destination_a", [
            "somepackage1/filename1", "somepackage2/filename2"
        ]), ("destination_b", ["somepackage3/filename3"])],
                         self.project.files_to_install)
        self.assertEqual([
            "somepackage1/filename1", "somepackage2/filename2",
            "somepackage3/filename3"
        ], self.project.manifest_included_files)