示例#1
0
    def test_copy(self):
        substitution = Substitution({'x': a})

        copy = substitution.__copy__()

        assert copy == substitution
        assert copy is not substitution
示例#2
0
 def test_extract_substitution(self, substitution, subject, pattern,
                               expected_result):
     substitution = Substitution(substitution)
     if expected_result is False:
         assert substitution.extract_substitution(subject, pattern) is False
     else:
         assert substitution.extract_substitution(subject, pattern) is True
         assert substitution == expected_result
示例#3
0
 def test_union_with_var(self, substitution, variable, value,
                         expected_result):
     substitution = Substitution(substitution)
     if expected_result is ValueError:
         with pytest.raises(ValueError):
             _ = substitution.union_with_variable(variable, value)
     else:
         result = substitution.union_with_variable(variable, value)
         assert result == expected_result
示例#4
0
 def test_union(self, substitution1, substitution2, expected_result):
     substitution1 = Substitution(substitution1)
     substitution2 = Substitution(substitution2)
     if expected_result is ValueError:
         with pytest.raises(ValueError):
             _ = substitution1.union(substitution2)
         with pytest.raises(ValueError):
             _ = substitution2.union(substitution1)
     else:
         result = substitution1.union(substitution2)
         assert result == expected_result
         assert result is not substitution1
         assert result is not substitution2
         result = substitution2.union(substitution1)
         assert result == expected_result
         assert result is not substitution1
         assert result is not substitution2
示例#5
0
 def __call__(self, match):
     self.called_with.append(Substitution(match))
     return self.return_value
示例#6
0
 def test_rename(self, substitution, renaming, expected_result):
     assert Substitution(substitution).rename(renaming) == expected_result