How to use the testtools.matchers.HasLength function in testtools

To help you get started, we’ve selected a few testtools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github snapcore / snapcraft / tests / unit / plugins / test_catkin.py View on Github external
def test_schema_include_roscore(self):
        schema = catkin.CatkinPlugin.schema()

        # Check include-roscore property
        include_roscore = schema["properties"]["include-roscore"]
        expected = ("type", "default")
        self.assertThat(include_roscore, HasLength(len(expected)))
        for prop in expected:
            self.assertThat(include_roscore, Contains(prop))
        self.assertThat(include_roscore["type"], Equals("boolean"))
        self.assertThat(include_roscore["default"], Equals(True))
github snapcore / snapcraft / tests / unit / plugins / test_catkin.py View on Github external
def test_schema(self):
        schema = catkin.CatkinPlugin.schema()

        properties = schema["properties"]
        expected = (
            "catkin-packages",
            "source-space",
            "include-roscore",
            "catkin-cmake-args",
            "underlay",
            "rosinstall-files",
            "recursive-rosinstall",
            "catkin-ros-master-uri",
        )
        self.assertThat(properties, HasLength(len(expected)))
        for prop in expected:
            self.assertThat(properties, Contains(prop))
github snapcore / snapcraft / tests / unit / plugins / test_autotools.py View on Github external
def test_get_build_properties(self):
        expected_build_properties = make.MakePlugin.get_build_properties() + (
            ["configflags", "install-via"]
        )
        resulting_build_properties = autotools.AutotoolsPlugin.get_build_properties()

        self.assertThat(
            resulting_build_properties, HasLength(len(expected_build_properties))
        )

        for property in expected_build_properties:
            self.assertIn(property, resulting_build_properties)
github openstack / oslo.service / tests / unit / test_periodic.py View on Github external
return 'baz'

        m = Manager()
        self.assertThat(m._periodic_tasks, matchers.HasLength(2))
        self.assertEqual(periodic_task.DEFAULT_INTERVAL,
                         m._periodic_spacing['foo'])
        self.assertEqual(4, m._periodic_spacing['bar'])
        self.assertThat(
            m._periodic_spacing, matchers.Not(matchers.Contains('baz')))

        @periodic_task.periodic_task
        def external():
            return 42

        m.add_periodic_task(external)
        self.assertThat(m._periodic_tasks, matchers.HasLength(3))
        self.assertEqual(periodic_task.DEFAULT_INTERVAL,
                         m._periodic_spacing['external'])
github snapcore / snapcraft / tests / unit / plugins / test_catkin.py View on Github external
def test_get_build_properties(self):
        expected_build_properties = ["catkin-cmake-args"]
        actual_build_properties = catkin.CatkinPlugin.get_build_properties()

        self.assertThat(
            actual_build_properties, HasLength(len(expected_build_properties))
        )

        for property in expected_build_properties:
            self.assertIn(property, actual_build_properties)
github snapcore / snapcraft / tests / unit / plugins / test_nodejs.py View on Github external
def test_get_pull_properties(self):
        expected_pull_properties = [
            "nodejs-version",
            "nodejs-package-manager",
            "nodejs-yarn-version",
        ]
        resulting_pull_properties = nodejs.NodePlugin.get_pull_properties()

        self.assertThat(
            resulting_pull_properties, HasLength(len(expected_pull_properties))
        )

        for property in expected_pull_properties:
            self.assertIn(property, resulting_pull_properties)
github snapcore / snapcraft / tests / unit / plugins / test_catkin.py View on Github external
def test_find_system_dependencies_local_only(self):
        self.assertThat(
            catkin._find_system_dependencies(
                {"foo", "bar"}, self.rosdep_mock, self.rospack_mock, self.catkin_mock
            ),
            HasLength(0),
        )

        self.rosdep_mock.get_dependencies.assert_has_calls(
            [mock.call("foo"), mock.call("bar")], any_order=True
        )
        self.rosdep_mock.resolve_dependency.assert_not_called()
        self.catkin_mock.find.assert_not_called()
github snapcore / snapcraft / tests / unit / plugins / test_maven.py View on Github external
def test_get_build_properties(self):
        expected_build_properties = ["maven-options", "maven-targets"]
        resulting_build_properties = maven.MavenPlugin.get_build_properties()

        self.assertThat(
            resulting_build_properties, HasLength(len(expected_build_properties))
        )

        for property in expected_build_properties:
            self.assertIn(property, resulting_build_properties)
github snapcore / snapcraft / tests / unit / plugins / test_colcon.py View on Github external
def test_schema_colcon_packages_ignore(self):
        schema = colcon.ColconPlugin.schema()

        # check colcon-packages-ignore property
        colcon_packages_ignore = schema["properties"]["colcon-packages-ignore"]
        expected = ("type", "default", "minitems", "items", "uniqueItems")
        self.assertThat(colcon_packages_ignore, HasLength(len(expected)))
        for prop in expected:
            self.assertThat(colcon_packages_ignore, Contains(prop))
        self.assertThat(colcon_packages_ignore["type"], Equals("array"))
        self.assertThat(colcon_packages_ignore["default"], Equals([]))
        self.assertThat(colcon_packages_ignore["minitems"], Equals(1))
        self.assertTrue(colcon_packages_ignore["uniqueItems"])
        self.assertThat(colcon_packages_ignore["items"], Contains("type"))
        self.assertThat(colcon_packages_ignore["items"]["type"], Equals("string"))
github snapcore / snapcraft / tests / unit / plugins / test_catkin.py View on Github external
underlay = schema["properties"]["underlay"]
        expected = ("type", "properties", "required")
        self.assertThat(underlay, HasLength(len(expected)))
        for prop in expected:
            self.assertThat(underlay, Contains(prop))
        self.assertThat(underlay["type"], Equals("object"))

        underlay_required = underlay["required"]
        expected = ("build-path", "run-path")
        self.assertThat(underlay_required, HasLength(len(expected)))
        for prop in expected:
            self.assertThat(underlay_required, Contains(prop))

        underlay_properties = underlay["properties"]
        expected = ("build-path", "run-path")
        self.assertThat(underlay_properties, HasLength(len(expected)))
        for prop in expected:
            self.assertThat(underlay_properties, Contains(prop))
        underlay_build_path = underlay_properties["build-path"]
        self.assertThat(underlay_build_path, Contains("type"))
        self.assertThat(underlay_build_path["type"], Equals("string"))
        underlay_run_path = underlay_properties["run-path"]
        self.assertThat(underlay_run_path, Contains("type"))
        self.assertThat(underlay_run_path["type"], Equals("string"))