assertraises Questions

2

Solved

The following question was triggered by the discussion in this post. Assume two files (foobar.py and foobar_unittest.py). File foobar.py contains a class (FooBar) with two functions (foo and bar)....
Speedway asked 18/2, 2016 at 19:36

4

The Python 2.7 unittest docs say: All the assert methods (except assertRaises(), assertRaisesRegexp()) accept a msg argument that, if specified, is used as the error message on failure … but ...
Cavefish asked 6/2, 2017 at 10:56

1

Solved

Is it possible to use assertRaises with multiple types of exceptions. Some thing like assertRaises(RuntimeError, "error message") assertRaises(Exception, "exception message") both these errors o...
Barbaric asked 17/9, 2018 at 20:16

1

Solved

I have created my custom exceptions as such within errors.py mapper = { 'E101': 'There is no data at all for these constraints', 'E102': 'There is no data for these constraints in this market,...

1

Can somebody tell me why the following unit-test is failing on the ValueError in test_bad, rather than catching it with assertRaises and succeeding? I think I'm using the correct procedure an...
Puccini asked 30/7, 2014 at 21:25

2

Solved

I am working on Exercise 49 of Learn Ruby the Hard Way The exercise asks to write a unit test for each function provided. One of the items I am testing is if a proper exception is raised. It is su...

3

Solved

I understand how to use assertRaises on a function or a lambda, but I wanted to use it on an instance method. So for example, if I have a class calculator that does infinite precision arithmetic, ...
Himself asked 7/1, 2013 at 15:44

2

Solved

One of my attributes is a property where the setter calls a validation function that raises an exception if the new value is invalid: pos.offset = 0 # @offset.setter calls validate(offset=0) # Pos...
1

© 2022 - 2024 — McMap. All rights reserved.