1
from testtools import TestCase
2
from testtools.matchers import (
5
from hwpack.testing import (
11
class TestMatchesStructure(TestCase):
14
def __init__(self, x):
17
def test_matches(self):
19
self.SimpleClass(1), MatchesStructure(x=Equals(1)))
21
def test_mismatch(self):
23
AssertionError, self.assertThat, self.SimpleClass(1),
24
MatchesStructure(x=NotEquals(1)))
26
def test_fromExample(self):
29
MatchesStructure.fromExample(self.SimpleClass(1), 'x'))
31
def test_update(self):
34
MatchesStructure(x=NotEquals(1)).update(x=Equals(1)))
36
def test_update_none(self):
39
MatchesStructure(x=Equals(1), y=NotEquals(42)).update(
43
class TestMatchesPackage(TestCase):
45
def test_simple(self):
46
observed = DummyFetchedPackage("foo", "1.1", architecture="armel")
47
expected = DummyFetchedPackage("foo", "1.1", architecture="armel")
49
observed, MatchesPackage.fromPackage(expected))
51
def test_mismatch(self):
52
observed = DummyFetchedPackage("foo", "1.1", depends="bar")
53
expected = DummyFetchedPackage("foo", "1.1", depends="baz")
54
self.assertRaises(AssertionError, self.assertThat, observed,
55
MatchesPackage.fromPackage(expected))
57
def test_skip_one_attribute(self):
58
observed = DummyFetchedPackage("foo", "1.1", depends="bar")
59
expected = DummyFetchedPackage("foo", "1.1", depends="baz")
62
MatchesPackage.fromPackage(expected).update(depends=None))