File: test_errors.py

package info (click to toggle)
python-pint 0.7.2-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 976 kB
  • ctags: 1,314
  • sloc: python: 8,113; makefile: 165
file content (19 lines) | stat: -rw-r--r-- 701 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# -*- coding: utf-8 -*-
from __future__ import division, unicode_literals, print_function, absolute_import


from pint.errors import DimensionalityError, UndefinedUnitError
from pint.testsuite import BaseTestCase

class TestErrors(BaseTestCase):

    def test_errors(self):
        x = ('meter', )
        msg = "'meter' is not defined in the unit registry"
        self.assertEqual(str(UndefinedUnitError(x)), msg)
        self.assertEqual(str(UndefinedUnitError(list(x))), msg)
        self.assertEqual(str(UndefinedUnitError(set(x))), msg)

        msg = "Cannot convert from 'a' (c) to 'b' (d)msg"
        ex = DimensionalityError('a', 'b', 'c', 'd', 'msg')
        self.assertEqual(str(ex), msg)