コード例 #1
0
    def test_validate_point_alternate_type(self):
        """Test the `_validate_point()` method with alternate types."""

        geo._validate_point({
            'a': 1,
            'b': 2
        },
                            alternate_type=collections.Mapping)
コード例 #2
0
ファイル: test_geo.py プロジェクト: dirn/Simon
    def test_validate_point_alternate_type_typeerror(self):
        ("Test that `_validate_point()` raises `TypeError` with "
         "alternate types.")

        with self.assertRaises(TypeError):
            geo._validate_point(1, alternate_type=str)

        with self.assertRaises(TypeError):
            geo._validate_point('a', alternate_type=int)
コード例 #3
0
    def test_validate_point_alternate_type_typeerror(self):
        ("Test that `_validate_point()` raises `TypeError` with "
         "alternate types.")

        with self.assertRaises(TypeError):
            geo._validate_point(1, alternate_type=str)

        with self.assertRaises(TypeError):
            geo._validate_point('a', alternate_type=int)
コード例 #4
0
ファイル: test_geo.py プロジェクト: dirn/Simon
    def test_validate_point_alternate_type_valueerror(self):
        ("Test that `_validate_point()` raises `ValueError` with "
         "alternate types.")

        with self.assertRaises(ValueError):
            geo._validate_point({'a': 1},
                                alternate_type=collections.Mapping)

        with self.assertRaises(ValueError):
            geo._validate_point({'a': 1, 'b': 2, 'c': 3},
                                alternate_type=collections.Mapping)
コード例 #5
0
    def test_validate_point_alternate_type_valueerror(self):
        ("Test that `_validate_point()` raises `ValueError` with "
         "alternate types.")

        with self.assertRaises(ValueError):
            geo._validate_point({'a': 1}, alternate_type=collections.Mapping)

        with self.assertRaises(ValueError):
            geo._validate_point({
                'a': 1,
                'b': 2,
                'c': 3
            },
                                alternate_type=collections.Mapping)
コード例 #6
0
ファイル: test_geo.py プロジェクト: dirn/Simon
    def test_validate_point_name(self):
        """Test the `_validate_point()` method with names."""

        with self.assertRaises(TypeError) as e:
            geo._validate_point(1, 'name')

        expected = 'name must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        with self.assertRaises(ValueError) as e:
            geo._validate_point([1], 'name')

        expected = 'name must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)
コード例 #7
0
    def test_validate_point_name(self):
        """Test the `_validate_point()` method with names."""

        with self.assertRaises(TypeError) as e:
            geo._validate_point(1, 'name')

        expected = 'name must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        with self.assertRaises(ValueError) as e:
            geo._validate_point([1], 'name')

        expected = 'name must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)
コード例 #8
0
ファイル: test_geo.py プロジェクト: dirn/Simon
    def test_validate_point_typeerror(self):
        """Test that `_validate_point()` raises `TypeError`."""

        # Test with a string
        with self.assertRaises(TypeError) as e:
            geo._validate_point('a')

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        # Test with an int
        with self.assertRaises(TypeError) as e:
            geo._validate_point(1)

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)
コード例 #9
0
    def test_validate_point_typeerror(self):
        """Test that `_validate_point()` raises `TypeError`."""

        # Test with a string
        with self.assertRaises(TypeError) as e:
            geo._validate_point('a')

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        # Test with an int
        with self.assertRaises(TypeError) as e:
            geo._validate_point(1)

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)
コード例 #10
0
ファイル: test_geo.py プロジェクト: dirn/Simon
    def test_validate_point_valueerror(self):
        """Test the `_validate_point()` method."""

        # Test with 1 element
        with self.assertRaises(ValueError) as e:
            geo._validate_point([1])

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        # Test with 3 elements
        with self.assertRaises(ValueError) as e:
            geo._validate_point([1, 2, 3])

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        # The following should not raise an exception
        geo._validate_point([1, 2])
        geo._validate_point((1, 2))
コード例 #11
0
    def test_validate_point_valueerror(self):
        """Test the `_validate_point()` method."""

        # Test with 1 element
        with self.assertRaises(ValueError) as e:
            geo._validate_point([1])

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        # Test with 3 elements
        with self.assertRaises(ValueError) as e:
            geo._validate_point([1, 2, 3])

        expected = '`point` must be a list containing exactly 2 elements'
        actual = str(e.exception)
        self.assertEqual(actual, expected)

        # The following should not raise an exception
        geo._validate_point([1, 2])
        geo._validate_point((1, 2))
コード例 #12
0
ファイル: test_geo.py プロジェクト: dirn/Simon
    def test_validate_point_alternate_type(self):
        """Test the `_validate_point()` method with alternate types."""

        geo._validate_point({'a': 1, 'b': 2},
                            alternate_type=collections.Mapping)