haarcuba / testix Goto Github PK
View Code? Open in Web Editor NEWMocking framework for Python with *exact* Scenarios
License: MIT License
Mocking framework for Python with *exact* Scenarios
License: MIT License
this is an extension of the __dynamic__
functionality.
I want this to be possible:
for i in range(10):
dynamicly_named_mock = Fake(f'name_{i}')
s.__from_fake__(dyamically_named_mock).some_method( 'arg1', 'arg2', ... )
currently only this works:
for i in range(10):
dynamicly_named_mock = Fake(f'name_{i}')
s.__dynamic__(f'name_{i}').some_method( 'arg1', 'arg2', ... )
when we use properties in classes, it's unclear how to fake it in our tests.
today, to set a property in some object I use:
### this code can happen anywhere before the flow
the_object = Fake('the_object')
the_object.some_property = 'some_value'
### now we return this object
s.the_flow() >> Fake('the_object')
i suggest adding kwargs to Fake class, so i can use Fake like this:
s.the_flow() >> Fake('the_object', some_property='some_value',... )
if patching an originally non-exising attribute, the current implementation will not clean it up
e.g.
patch_module(tested_module, 'paramiko', exclude=['ssh_exception'])
this way, tested code can refer to paramiko exceptions and still be tested with a fake 'paramiko' module.
this is because pprint.pformat
breaks long strings and displayes them as tuples.
solution:
use pprint.pformat(width=HUGE_NUMBER)
create some more documentation
the http server was a bad idea, lets do live monitoring
something like
with s.tempfile.TemporaryFile() as f
s.__from_fake__(f).read()
run_some_code()
and the code is
with tempfile.TemporaryFile() as f:
f.read()
example:
E === Scenario XXXX ===
E expected: fake_object.get() (/path/to/file.py:65)
E actual : fake_object.get(parameter)
e.g.
s.some_func() >> async_result(Fake('whatever'))
this is essentialy like IgnoreArgument
but for an entire function call, e.g.
s.call_me(IgnoreAll())
and then the code can do any of the following:
call_me(1,2,3,x=1,y=2)
call_me()
call_me(x=1)
write the server, TDD, with unit tests
e.g.:
E testix: ExpectationException
E testix details:
E expected: tempfile.NamedTemporaryFile()
E actual : tempfile.NamedTemporaryFile(mode = 'w')
but the test specified mode="w"
and the code called without it.
in short, the actual
and expected
are reversed here.
include the custom value thing
make e2e test in docs fail properly
e.g.
@pytest.mark.asyncio
async def test_async_context_managers(self):
with scenario.Scenario('async context managers') as s:
s.__async_with__.open('/path/to/file', 'rw') >> fake.Fake('my_file')
s.__await_on__.my_file.read(500) >> 'some text'
s.my_file.seek(0)
s.__await_on__.my_file.write('more text')
open_mock = fake.Fake('open')
async with open_mock('/path/to/file', 'rw') as my_file:
assert await my_file.read(500) == 'some text'
my_file.seek(0)
my_file.write('more text')
# ^^^^ this line should have an await, but we don't catch this
create basic documentation project and host it
more docs
e.g.
E Failed:
E testix: ExpectationException
E testix details:
E expected: thingy.insert()
E actual : thingy.set(status, failed)
it should be actual: thingy.set('status', 'failed')
i.e.
s.my_mock.some_call(555).throwing(Exception)
should be
s.my_sock.some_call(555) >> throwin(Exception)
we want
with Scenario(title='some-name') as s:
...
this can be used to prettify some prints, and also increase tests readability.
if we fake pathlib, the code under test may try to use /
- in such a case
we need to return a new fake with the new path
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.