<commit_before>>>> from should_dsl import should, should_not, add_predicate_regex

>>> class Foo(object):
...     def __init__(self, valid=True):
...         self.valid = valid
...         self.sleeping = True
...         self._doing_some_private_things = False
...     def __str__(self):
...         return '<foo object>'

>>> Foo() |should| be_valid

>>> Foo() |should_not| be_valid
Traceback (most recent call last):
    ...
ShouldNotSatisfied: expected valid to be False, got True

>>> Foo(False) |should| be_valid
Traceback (most recent call last):
    ...
ShouldNotSatisfied: expected valid to be True, got False

>>> Foo(False) |should_not| be_valid

>>> Foo() |should| be_sleeping

>>> Foo() |should_not| be_sleeping
Traceback (most recent call last):
    ...
ShouldNotSatisfied: expected sleeping to be False, got True




>>> be_valid
Traceback (most recent call last):
    ...
NameError: name 'be_valid' is not defined

>>> Foo() |should| be_valid

>>> be_valid
Traceback (most recent call last):
    ...
NameError: name 'be_valid' is not defined



>>> Foo() |should| be_doing_some_private_things
Traceback (most recent call last):
    ...
NameError: name 'be_doing_some_private_things' is not defined

>>> Foo() |should| be__doing_some_private_things
Traceback (most recent call last):
    ...
NameError: name 'be__doing_some_private_things' is not defined



>>> be_valid = 'hey, i exist!!'
>>> Foo() |should| be_valid

>>> be_valid
'hey, i exist!!'



>>> add_predicate_regex(r'is_really_(.+)')
>>> class Integer(int):
...     def __init__(self, value):
...         self.is_really_positive = value >= 0
...         self.isodd = (value % 2 == 1) 
>>> Integer(10) |should| be_positive
>>> Integer(1) |should| be_odd

>>> class Float(float):
...     def __init__(self, value):
...         self.is_negative = value < 0
>>> Float(-1) |should| be_negative
<commit_msg>Adding test for when an object has a predicate matcher generated for it that matches an existing matcher. Also tests that the predicate matcher will override the existing matcher<commit_after>>>> from should_dsl import should, should_not, add_predicate_regex

>>> class Foo(object):
...     def __init__(self, valid=True):
...         self.valid = valid
...         self.sleeping = True
...         self._doing_some_private_things = False
...     def __str__(self):
...         return '<foo object>'

>>> Foo() |should| be_valid

>>> Foo() |should_not| be_valid
Traceback (most recent call last):
    ...
ShouldNotSatisfied: expected valid to be False, got True

>>> Foo(False) |should| be_valid
Traceback (most recent call last):
    ...
ShouldNotSatisfied: expected valid to be True, got False

>>> Foo(False) |should_not| be_valid

>>> Foo() |should| be_sleeping

>>> Foo() |should_not| be_sleeping
Traceback (most recent call last):
    ...
ShouldNotSatisfied: expected sleeping to be False, got True




>>> be_valid
Traceback (most recent call last):
    ...
NameError: name 'be_valid' is not defined

>>> Foo() |should| be_valid

>>> be_valid
Traceback (most recent call last):
    ...
NameError: name 'be_valid' is not defined



>>> Foo() |should| be_doing_some_private_things
Traceback (most recent call last):
    ...
NameError: name 'be_doing_some_private_things' is not defined

>>> Foo() |should| be__doing_some_private_things
Traceback (most recent call last):
    ...
NameError: name 'be__doing_some_private_things' is not defined



>>> be_valid = 'hey, i exist!!'
>>> Foo() |should| be_valid

>>> be_valid
'hey, i exist!!'



>>> add_predicate_regex(r'is_really_(.+)')
>>> class Integer(int):
...     def __init__(self, value):
...         self.is_really_positive = value >= 0
...         self.isodd = (value % 2 == 1) 
>>> Integer(10) |should| be_positive
>>> Integer(1) |should| be_odd

>>> class Float(float):
...     def __init__(self, value):
...         self.is_negative = value < 0
>>> Float(-1) |should| be_negative


>>> from should_dsl import should_not
>>> class EmptyObject(object):
...     def __len__(self):
...         return 0
...
...     def __zero__(self):
...         return True
... 
>>> obj = EmptyObject()
>>> obj |should| be_empty
>>> obj.empty = False
>>> obj |should_not| be_empty
>>> del obj.empty
>>> obj |should| be_empty
{'fraction_non_alphanumeric': 0.14938737040527805, 'fraction_numerical': 0.004005655042412818, 'mean_word_length': 3.4731296101159117, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 163, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4728367', 'n_tokens_mistral': 1420, 'n_tokens_neox': 1320, 'n_words': 409}