Equivalent of NUnit or Jasmine statements for Python?

Using the Python unittest, I found that I lacked clean, descriptive ways to write unit test statements, such as those made in NUnit or Jasmine :

# NUnit Expect(collection, Has.None.EqualTo(DateTime.Now).Within(3).Hours); # Jasmine expect(pi).not.toBeCloseTo(e, 2); 

Is there an existing Python library that provides such assertion methods, preferably compatible with the Python unittest library?

+6
source share
1 answer

What about PyHamcrest ?

 assert_that(biscuit, equal_to(biscuit)) assert_that(biscuit, instance_of(Biscuit)) assert_that(biscuit, is_in(jar)) 

more matches: https://github.com/hamcrest/PyHamcrest#predefined-matchers

0
source

Source: https://habr.com/ru/post/1202324/


All Articles