More fun with Python development
Project description
Flowp is a library which tries to bring the best ideas from Ruby / node.js world to Python making development more fun. For version 1.0 module flowp.testing is avaiable which allows to write tests in a RSpec BDD style with minimum of magic.
Installation
$ pip3 install flowp
Quick start
Test subject (mymodule.py):
class SomeObject:
def __init__(self, logger=None):
self._logger = logger
def count(self, *args):
positives = 0
for arg in args:
if arg > 0:
positives += 1
if self._logger:
self._logger.info(positives)
else:
return positives
Behavior specyfication (spec_mymodule.py):
import mymodule
from flowp.testing import Behavior, when, expect
from unittest import mock
class SomeObject(Behavior):
def before_each(self):
self.subject = mymodule.SomeObject()
def logger_given(self):
self.logger = mock.Mock()
self.subject = mymodule.SomeObject(self.logger)
def it_counts_positive_numbers(self):
expect(self.subject.count(-1, 2, -3, 4)) == 2
@when(logger_given)
def it_sends_results_to_logger(self):
self.subject.count(-1, 2, -3, 4)
expect(self.logger.info).called_with(2)
Then run:
$ python3 -m flowp.testing -v
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
flowp-1.0.tar.gz
(7.1 kB
view hashes)