Package: kids.test
kids.testis a Python library providing helpers when writing tests
in python. It’s part of ‘Kids’ (for Keep It Dead Simple) library.MaturityThis is alpha release. It’s only a repository with a few recipes and holds very
few interests. It might be more consistent in the future.It lacks any sensible documentation and has nothing ground breaking in its core.Featuresusingkids.test:You can use a replacementunittestclass that ensure that you have some
python3 additions likeassertContainsorassertRegex.You can useBaseTmpDirTestthat creates a temporary directory before
executing tests, and delete it at the end.InstallationYou don’t need to download the GIT version of the code askids.testis
available on the PyPI. So you should be able to run:pip install kids.testIf you have downloaded the GIT sources, then you could add install
the current version via traditional:python setup.py installAnd if you don’t have the GIT sources but would like to get the latest
master or branch from github, you could also:pip install git+https://github.com/0k/kids.testOr even select a specific revision (branch/tag/commit):pip install git+https://github.com/0k/kids.test@masterUsageTestTestis the base class for all unittest inkids.*framework. It provides
some missing.assert*()method to python 2:>>> from kids.test import Test, run

>>> class MyTest(Test):
...    def test_foo(self):
...        self.assertRegex('foo', 'fo+')
...        self.assertContains('bar foo hop', 'foo')
...        self.assertNotContains('bar fou hop', 'foo')
...    def test_failing_regex(self):
...        self.assertRegex('foo', 'xfo+')
...    def test_failing_contains(self):
...        self.assertContains('bar fou hop', 'foo')
...    def test_failing_not_contains(self):
...        self.assertNotContains('bar foo hop', 'foo')

>>> run(MyTest)
FFF.
...
AssertionError: ...'bar fou hop' should contain 'foo'.
...
AssertionError: ...'bar foo hop' should not contain 'foo'.
...
AssertionError: ...'foo' should match regex 'xfo+'.
...
Ran 4 tests in ...s
<BLANKLINE>
FAILED (failures=3)
<BLANKLINE>BaseTmpDirTestThis unittest class will ensure that the current work dir (CWD) before
executing test, is an empty temporary directory. And it’ll ensure this directory
will be deleted at the end:>>> from kids.test import BaseTmpDirTest, run

>>> class MyTest(BaseTmpDirTest):
...    def test_foo(self):
...        import glob
...        self.assertEqual(len(glob.glob('*')), 0)

>>> run(MyTest)
.
----------------------------------------------------------------------
Ran 1 test in ...s
<BLANKLINE>
OK
<BLANKLINE>Here’s what happens behing the scene, let’s use minimock to show the
creation and deletion of directory:>>> import minimock

>>> import tempfile, shutil, os

>>> minimock.mock('tempfile.mkdtemp', returns='/tmp/tempdir')
>>> minimock.mock('os.chdir', returns='/tmp/tempdir')
>>> minimock.mock('shutil.rmtree')

>>> class MyTest(BaseTmpDirTest):
...    def test_foo(self):
...        print("running test")
...        self.assertTrue(True)

>>> run(MyTest)
Called tempfile.mkdtemp()
Called os.chdir('/tmp/tempdir')
running test
Called os.chdir('...')
Called shutil.rmtree('/tmp/tempdir')
.
----------------------------------------------------------------------
Ran 1 test in ...s
<BLANKLINE>
OK
<BLANKLINE>

>>> minimock.restore()ContributingAny suggestion or issue is welcome. Push request are very welcome,
please check out the guidelines.Push Request GuidelinesYou can send any code. I’ll look at it and will integrate it myself in
the code base and leave you as the author. This process can take time and
it’ll take less time if you follow the following guidelines:check your code with PEP8 or pylint. Try to stick to 80 columns wide.separate your commits per smallest concern.each commit should pass the tests (to allow easy bisect)each functionality/bugfix commit should contain the code, tests,
and doc.prior minor commit with typographic or code cosmetic changes are
very welcome. These should be tagged in their commit summary with!minor.the commit message should follow gitchangelog rules (check the git
log to get examples)if the commit fixes an issue or finished the implementation of a
feature, please mention it in the summary.If you have some questions about guidelines which is not answered here,
please check the currentgit log, you might find previous commit that
would show you how to deal with your issue.LicenseCopyright (c) 2015 Valentin Lab.Licensed under theBSD License.Changelog0.0.1 (2015-02-04)First import. [Valentin Lab]