pymore

Mo python, less problems. Helpful python utilities.


Keywords
python-testing
License
Apache-2.0
Install
pip install pymore==0.1.3

Documentation

pymore

pymore is a collection of useful utilities for Python.

Test all the code PyPI version

This includes

  • EqualsTester: a helper for testing the equality contract in Python (originally developed for Cirq)
import pymore

tester = pymore.EqualsTester()

# This tests that the added elements all satisfy the equals contract
# between themselves.
tester.add_equality_group(MyObject("a"), MyObject("a"))

# Each new addition of an equality group also tests that the elements
# in this new group are not equal to those in the perviously added group.
# So, for example, this would raise an `AssertionError` if it was
# true that `MyObject("a")` was equal to `MyObject("b")`.
tester.add_equality_group(MyObject("b"), MyObject("b"))
  • first: Return the first element that matches a predicate, or a default.
import pymore

is_even = lambda x: x % 2 == 0
# Returns the first element that is even.
first = pymore.first([1, 3, 6, 7], is_even)
assert first == 6

License

This package is licensed under an Apache 2.0 license. This code is derived from work in other frameworks. See LICENSE and NOTICES for details.