jeffh / describe Goto Github PK
View Code? Open in Web Editor NEWAn experimental Python BDD tool.
License: MIT License
An experimental Python BDD tool.
License: MIT License
Describe needs better assertions for certain datatypes. In particular, lists, tuples, and dictionaries.
A good place to start is to use datadiff:
Similar to RSpec's recieve counts:
my_mock.should_receive(:msg).once
my_mock.should_receive(:msg).exactly(n).times
my_mock.should_receive(:msg).at_least(:once)
# An exception is raised if the message is never received or is received only once.
my_mock.should_receive(:msg).at_least(:twice)
# An exception is raised if the message is received fewer than n times.
my_mock.should_receive(:msg).at_least(n).times
# An exception is raised if the message is received more than once
# (does not raise if message is never receieved).
my_mock.should_receive(:msg).at_most(:once)
# An exception is raised if the message is received more than twice
# (does not raise if message is never receieved).
my_mock.should_receive(:msg).at_most(:twice)
# An exception is raised if the message is received more than n times
# (does not raise if message is never receieved).
my_mock.should_receive(:msg).at_most(n).times
#Explicitly Imprecise Counts
my_mock.should_receive(:msg).any_number_of_times
A direct mapping in describe seems the most intuitive.
See the RSpec ordering calls.
Example RSpec code:
my_mock.should_receive(:flip).once.ordered
my_mock.should_receive(:flop).once.ordered
flip should be called before flop.
Only methods marked with order should be concerned with order:
my_mock.should_receive(:zero)
my_mock.should_receive(:one).ordered
my_mock.should_receive(:two).ordered
my_mock.should_receive(:one_and_a_half)
# This will pass:
my_mock.one
my_mock.one_and_a_half
my_mock.zero
my_mock.two
This seems to still be the most intuitive method. Perhaps an optional argument to explicitly specify the order.
I have define a class with several mehotds, so now Im trying to execute it from the command line (terminal) but I can't find anywhere in your documentation how to run this.
From RSpec's section on yielding:
my_mock.should_receive(:msg).once.and_yield(<value-1>, <value-2>, ..., <value-n>)
When the expected message is received, the mock will yield the values to the passed block.
To mock a method which yields values multiple times, and_yield can be chained.
my_mock.should_receive(:msg).once.and_yield(<value-0-1>, <value-0-2>, ..., <value-0-n>).
and_yield(<value-1-1>, <value-1-2>, ..., <value-1-n>).
and_yield(<value-2-1>, <value-2-2>, ..., <value-2-n>)
For python we should accept one of a view things:
mock.should_access.foo().and_yield(1,2,3)
# or
def generation():
[1,2,3]
mock.should_access.foo().and_generate(generation)
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.