{"id":17836179,"url":"https://github.com/mdw-archives/pyspecs","last_synced_at":"2025-07-29T03:33:07.567Z","repository":{"id":3205128,"uuid":"4238949","full_name":"mdw-archives/pyspecs","owner":"mdw-archives","description":"Minimalistic BDD in Python (ah, my first forray into the wonderful world of test runners!)","archived":false,"fork":false,"pushed_at":"2021-05-20T16:28:17.000Z","size":169,"stargazers_count":40,"open_issues_count":5,"forks_count":3,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-11-19T10:54:49.639Z","etag":null,"topics":["bdd-framework","python2","tdd-utilities","testing-tools"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mdw-archives.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-05-06T06:28:39.000Z","updated_at":"2024-10-19T03:57:07.000Z","dependencies_parsed_at":"2022-08-19T13:00:59.693Z","dependency_job_id":null,"html_url":"https://github.com/mdw-archives/pyspecs","commit_stats":null,"previous_names":["mdw-archives/pyspecs"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdw-archives%2Fpyspecs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdw-archives%2Fpyspecs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdw-archives%2Fpyspecs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mdw-archives%2Fpyspecs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mdw-archives","download_url":"https://codeload.github.com/mdw-archives/pyspecs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227685884,"owners_count":17804136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bdd-framework","python2","tdd-utilities","testing-tools"],"created_at":"2024-10-27T20:34:03.414Z","updated_at":"2024-12-03T18:36:17.921Z","avatar_url":"https://github.com/mdw-archives.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pyspecs - Minimalistic BDD in Python\n====================================\n\n![Build Status](https://travis-ci.org/mdwhatcott/pyspecs.png)\n\npyspecs is a testing framework that strives to achieve more readable\nspecifications (tests) by leveraging some fancy syntactic sugar and\nauto-discovery of tests/specs.  WARNING: version 2.0 introduces breaking\nchanges if you've been using 1.0 or 1.1.\n\nInstallation is straightforward:\n\n    $ pip install pyspecs\n\nor...\n\n    $ easy_install pyspecs\n\nor...\n\n    $ git clone https://mdwhatcott@github.com/mdwhatcott/pyspecs.git\n    $ cd pyspecs\n    $ python setup.py\n\n\n## Assertions\n\nThe main tool for verifying behavior is an assertion of some kind. The\nsimplest assertion can be made by using the built-in assert statement:\n\n    assert 42 == 'The answer the life, the universe and everything'\n\nFor readability this project provides a more fluent method for making\nassertions:\n\n\n\t# These imported names are all synonyms for the class that\n\t# provides fluent assertions (Should). Use whichever provides\n\t# the best readability.  The general patter is:\n\t# \u003e\u003e\u003e the([value]).should.[condition_method]([comparison_args])\n\t#  or...\n\t# \u003e\u003e\u003e the([value]).should_NOT.[condition_method]([comparison_args]) # negated!\n\n\tfrom pyspecs import the, this, that, it\n\n\n\tthis(42).should.equal(42) # this passes\n\n\tthis([1, 2, 3]).should.contain(2) # this also passes\n\n\tthe(list()).should.be_empty() # passes\n\n\tit(1).should_NOT.be_greater_than(100) # passes\n\n\t# raises AssertionError, caught by framework, logged as failure\n\tthat(200).should.be_less_than(0)\n\n\n\n## Writing complete specs\n\n    from pyspecs import given, when, then, and_, the\n\n\n    with given.two_operands:\n        a = 2\n        b = 3\n\n        with when.supplied_to_the_add_function:\n            total = a + b\n\n            with then.the_total_should_be_mathmatically_correct:\n                the(total).should.equal(5)\n\n            with and_.the_total_should_be_greater_than_either_operand:\n                the(total).should.be_greater_than(a)\n                the(total).should.be_greater_than(b)\n\n        with when.supplied_to_the_subtract_function:\n            difference = b - a\n\n            with then.the_difference_should_be_mathmatically_correct:\n                the(difference).should.equal(1)\n\n        # cleanup is just based on scope\n        del a, b, total, difference\n\n\nNotice that the names of each step are supplied as dynamic attributes of the\n`given`, `when`, `then`, and `and_` step keywords. These user-created attributes\nare used in the output (below).  Here is a listing of words that can be\nused as steps:\n\n- `given`\n- `provided`\n- `when`\n- `then`\n- `and_`\n- `so`\n- `therefore`\n- `however`\n- `as_well_as`\n\nThese steps can be arranged in any order and hierarchy for compose a\nspecification (spec).  You can even create your own steps that suit your needs \n(see the source code for how that's done).\n\n\n## Execution of specs\n\nBeyond providing the python library which will be explained below, installation\nprovides a command-line script into the environment, meant to be invoked\nfrom the root of your project.  The script will execute all specs in .py files\nending in 'test.py' or 'tests.py' or beginning with 'test'.\n\nTo run all tests once:\n\n    $ run_pyspecs.py\n\nTo begin an auto-test loop (runs all specs anytime a .py file is saved):\n\n\n    $ run_pyspecs.py -w\n\n\n### Complete Example\n\nThere are some complete examples of specs, code, and output in the\n[examples folder](https://github.com/mdwhatcott/pyspecs/tree/master/examples).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdw-archives%2Fpyspecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmdw-archives%2Fpyspecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmdw-archives%2Fpyspecs/lists"}