Merge lp:~msabramo/capturemock/tests_add_mutable_mapping_replay into lp:~geoff.bache/capturemock/tests

Proposed by Marc Abramowitz
Status: Merged
Merged at revision: 134
Proposed branch: lp:~msabramo/capturemock/tests_add_mutable_mapping_replay
Merge into: lp:~geoff.bache/capturemock/tests
Diff against target: 90 lines (+45/-0)
7 files modified
python_attributes/objects/mutable_mapping/replay/capturemock/test.mock (+7/-0)
python_attributes/objects/mutable_mapping/replay/catalogue.cpmock (+1/-0)
python_attributes/objects/mutable_mapping/replay/knownbugs.cpmock (+8/-0)
python_attributes/objects/mutable_mapping/replay/moduletomock.py (+15/-0)
python_attributes/objects/mutable_mapping/replay/stdout.cpmock (+1/-0)
python_attributes/objects/mutable_mapping/replay/target.py (+11/-0)
python_attributes/objects/mutable_mapping/testsuite.cpmock (+2/-0)
To merge this branch: bzr merge lp:~msabramo/capturemock/tests_add_mutable_mapping_replay
Reviewer Review Type Date Requested Status
Geoff Bache Pending
Review via email: mp+198497@code.launchpad.net

Description of the change

Hi Geoff,

So the fixes we did fixed **recording** of collections.MutableMapping objects, but unfortunately **replay** is still broken with the same metaclass error.

Here is a TextTest test that shows it.

To post a comment you must log in.
Revision history for this message
Geoff Bache (geoff.bache) wrote :

Thanks for this, I've merged it. This time, the main change was to move several copied files to the parent directory and remove the copies: TextTest works hierarchically like this to avoid duplicating data.

Might have known we'd need a replay test for this, really. I'll take a look now.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added directory 'python_attributes/objects/mutable_mapping/record'
2=== renamed file 'python_attributes/objects/mutable_mapping/catalogue.cpmock' => 'python_attributes/objects/mutable_mapping/record/catalogue.cpmock'
3=== renamed file 'python_attributes/objects/mutable_mapping/knownbugs.cpmock' => 'python_attributes/objects/mutable_mapping/record/knownbugs.cpmock'
4=== renamed file 'python_attributes/objects/mutable_mapping/moduletomock.py' => 'python_attributes/objects/mutable_mapping/record/moduletomock.py'
5=== renamed file 'python_attributes/objects/mutable_mapping/recorded_mock.cpmock' => 'python_attributes/objects/mutable_mapping/record/recorded_mock.cpmock'
6=== renamed file 'python_attributes/objects/mutable_mapping/stderr.cpmock' => 'python_attributes/objects/mutable_mapping/record/stderr.cpmock'
7=== renamed file 'python_attributes/objects/mutable_mapping/stdout.cpmock' => 'python_attributes/objects/mutable_mapping/record/stdout.cpmock'
8=== renamed file 'python_attributes/objects/mutable_mapping/target.py' => 'python_attributes/objects/mutable_mapping/record/target.py'
9=== added directory 'python_attributes/objects/mutable_mapping/replay'
10=== added directory 'python_attributes/objects/mutable_mapping/replay/capturemock'
11=== added file 'python_attributes/objects/mutable_mapping/replay/capturemock/test.mock'
12--- python_attributes/objects/mutable_mapping/replay/capturemock/test.mock 1970-01-01 00:00:00 +0000
13+++ python_attributes/objects/mutable_mapping/replay/capturemock/test.mock 2013-12-11 06:05:46 +0000
14@@ -0,0 +1,7 @@
15+<-PYT:import moduletomock
16+<-PYT:moduletomock.__path__
17+->RET:raise exceptions.AttributeError("'module' object has no attribute '__path__'")
18+<-PYT:moduletomock.MyDict(animal='dog')
19+->RET:Instance('MyDict(_abcoll.MutableMapping)', 'mydict_dog')
20+<-PYT:mydict_dog.__getitem__('animal')
21+->RET:'dog'
22
23=== added file 'python_attributes/objects/mutable_mapping/replay/catalogue.cpmock'
24--- python_attributes/objects/mutable_mapping/replay/catalogue.cpmock 1970-01-01 00:00:00 +0000
25+++ python_attributes/objects/mutable_mapping/replay/catalogue.cpmock 2013-12-11 06:05:46 +0000
26@@ -0,0 +1,1 @@
27+No files or directories were created, edited or deleted.
28
29=== added file 'python_attributes/objects/mutable_mapping/replay/knownbugs.cpmock'
30--- python_attributes/objects/mutable_mapping/replay/knownbugs.cpmock 1970-01-01 00:00:00 +0000
31+++ python_attributes/objects/mutable_mapping/replay/knownbugs.cpmock 2013-12-11 06:05:46 +0000
32@@ -0,0 +1,8 @@
33+
34+[Reported by geoff at 08Dec22:13:21]
35+search_string:metaclass conflict: the metaclass of a derived clas
36+use_regexp:0
37+search_file:stderr
38+ignore_other_errors:1
39+full_description:No support for intercepting objects derived from Abstract Base Classes currently. See LP bug 1256218
40+brief_description:LP bug 1256218
41
42=== added file 'python_attributes/objects/mutable_mapping/replay/moduletomock.py'
43--- python_attributes/objects/mutable_mapping/replay/moduletomock.py 1970-01-01 00:00:00 +0000
44+++ python_attributes/objects/mutable_mapping/replay/moduletomock.py 2013-12-11 06:05:46 +0000
45@@ -0,0 +1,15 @@
46+from collections import MutableMapping
47+
48+class MyDict(MutableMapping):
49+ def __init__(self, **kwargs):
50+ self._dict = dict(kwargs)
51+ def __delitem__(self):
52+ del self._dict[key]
53+ def __getitem__(self, key):
54+ return self._dict[key]
55+ def __setitem__(self, key, val):
56+ self._dict[key] = val
57+ def __iter__(self):
58+ return iter(self._dict)
59+ def __len__(self):
60+ return len(self._dict)
61
62=== added file 'python_attributes/objects/mutable_mapping/replay/stderr.cpmock'
63=== added file 'python_attributes/objects/mutable_mapping/replay/stdout.cpmock'
64--- python_attributes/objects/mutable_mapping/replay/stdout.cpmock 1970-01-01 00:00:00 +0000
65+++ python_attributes/objects/mutable_mapping/replay/stdout.cpmock 2013-12-11 06:05:46 +0000
66@@ -0,0 +1,1 @@
67+mutable_mapping["animal"] = 'dog'
68
69=== added file 'python_attributes/objects/mutable_mapping/replay/target.py'
70--- python_attributes/objects/mutable_mapping/replay/target.py 1970-01-01 00:00:00 +0000
71+++ python_attributes/objects/mutable_mapping/replay/target.py 2013-12-11 06:05:46 +0000
72@@ -0,0 +1,11 @@
73+from capturemock import capturemock, REPLAY
74+
75+@capturemock('moduletomock', mode=REPLAY)
76+def test():
77+ from moduletomock import MyDict
78+
79+ mutable_mapping = MyDict(animal='dog')
80+
81+ print('mutable_mapping["animal"] = %r' % mutable_mapping["animal"])
82+
83+test()
84
85=== added file 'python_attributes/objects/mutable_mapping/testsuite.cpmock'
86--- python_attributes/objects/mutable_mapping/testsuite.cpmock 1970-01-01 00:00:00 +0000
87+++ python_attributes/objects/mutable_mapping/testsuite.cpmock 2013-12-11 06:05:46 +0000
88@@ -0,0 +1,2 @@
89+record
90+replay

Subscribers

People subscribed via source and target branches

to all changes: