Example #1
0
class TestErrors:

    def setup(self):
        with open('tests/test_errors.json') as js:
            self.j = json.load(js)
        self.e = Errors()

    def test_load_json(self):
        assert self.e._errors == self.j

    def test_load_json_no_file(self):
        with pytest.raises(IOError):
            Errors('dont_exists.json')

    def test_load_json_falty_file(self):
        with pytest.raises(ValueError):
            Errors('imp_errors.py')

    def test_lookup_unknown_errno(self):
        with pytest.raises(ErrorsError, message="Unknown error number: 666"):
            self.e.lookup(666)

    def test_lookup_error(self, errno):
        err = self.j[str(errno)]
        msg = self.e.lookup(errno)

        assert err == msg
Example #2
0
class TestErrors(object):

    def setup(self):
        with open('tests/test_errors.json') as js:
            self.j = json.load(js)
        self.e = Errors()

    def test_load_json(self):
        assert self.e._errors == self.j

    # pylint: disable=no-self-use
    def test_load_json_no_file(self):
        with pytest.raises(IOError):
            Errors('dont_exists.json')

    # pylint: disable=no-self-use
    def test_load_json_falty_file(self):
        with pytest.raises(ValueError):
            Errors('imp_errors.py')

    def test_lookup_unknown_errno(self):
        with pytest.raises(ErrorsError) as e:
            self.e.lookup(666)
        assert e.value.message == "Unknown error number: 666"

    def test_lookup_error(self, errno):
        err = self.j[str(errno)]
        msg = self.e.lookup(errno)

        assert err == msg
Example #3
0
class TestErrors:
    def setup(self):
        with open('tests/test_errors.json') as js:
            self.j = json.load(js)
        self.e = Errors()

    def test_load_json(self):
        assert self.e._errors == self.j

    def test_load_json_no_file(self):
        with pytest.raises(IOError):
            Errors('dont_exists.json')

    def test_load_json_falty_file(self):
        with pytest.raises(ValueError):
            Errors('imp_errors.py')

    def test_lookup_unknown_errno(self):
        with pytest.raises(ErrorsError, message="Unknown error number: 666"):
            self.e.lookup(666)

    def test_lookup_error(self, errno):
        err = self.j[str(errno)]
        msg = self.e.lookup(errno)

        assert err == msg
Example #4
0
 def setup(self):
     with open('tests/test_errors.json') as js:
         self.j = json.load(js)
     self.e = Errors()
Example #5
0
 def test_load_json_falty_file(self):
     with pytest.raises(ValueError):
         Errors('imp_errors.py')
Example #6
0
 def test_load_json_no_file(self):
     with pytest.raises(IOError):
         Errors('dont_exists.json')
Example #7
0
 def setup(self):
     with open('tests/test_errors.json') as js:
         self.j = json.load(js)
     self.e = Errors()