def build_version_test(name, version_case):
    class Tests(TestCase):

        def test_flocker_version(self):
            """
            The parsed version matches the expected parsed version.
            """
            self.assertEqual(
                parse_version(version_case.version),
                version_case.flocker_version,
                "Version doesn't match expected parsed version.",
            )

        def test_doc_version(self):
            """
            The calculated doc version matches the expected doc version.",
            """
            self.assertEqual(
                get_doc_version(version_case.version),
                version_case.doc_version,
                "Calculated doc version doesn't match expected doc version.",
            )

        @skipIf(
            version_case.is_legacy,
            "Legacy version don't generate proper installable version.")
        def test_installable_version(self):
            """
            The calculated installable version matches the expected installable
            version.
            """
            self.assertEqual(
                get_installable_version(version_case.version),
                version_case.installable_version,
                "Calculated installable version doesn't match"
                "expected installable version.",)

        def test_is_release(self):
            """
            ``is_release`` returns the expected value for the version.
            """
            self.assertEqual(
                is_release(version_case.version),
                version_case.is_release,
            )

        def test_is_weekly_release(self):
            """
            ``is_weekly_release`` returns the expected value for the version.
            """
            self.assertEqual(
                is_weekly_release(version_case.version),
                version_case.is_weekly_release,
            )

        def test_is_pre_release(self):
            """
            ``is_pre_release`` returns the expected value for the version.
            """
            self.assertEqual(
                is_pre_release(version_case.version),
                version_case.is_pre_release,
            )

        @skipUnless(PACKAGING_INSTALLED, "``packaging`` not installed.")
        def test_pep_440(self):
            """
            The version is a valid PEP440 version.

            (``PEP440Version`` raises if provided an invalid version).
            """
            PEP440Version(version_case.version)

        @skipUnless(PACKAGING_INSTALLED, "``packaging`` not installed.")
        @skipIf(version_case.is_legacy, "Legacy version isn't normalized.")
        def test_normalization(self):
            """
            The version number is normalized according to PEP440.
            """
            self.assertEqual(
                version_case.version,
                str(PEP440Version(version_case.version)),
                "Version isn't normalized.",
            )

    Tests.__name__ = name
    return Tests
Close I/O established in "open".
dataset/ETHPy150Open ClusterHQ/flocker/flocker/common/test/test_version.py/build_version_test--crossover with--dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/imaplib.py/IMAP4_stream.shutdown