Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
code-contracts is a library that provides:
unittest.TestCase
.The goal of this library is not to make Python a statically-typed language. Instead, it aims to help you define what is expected from your code before it executes, so that you can more easily track and prevent bugs.
So here's how you can use contracts:
.. code-block:: python
from contracts import contract
def build_rocket(name, model, company):
contract.is_not_empty(name)
contract.is_greater_than(model, 0)
contract.is_not_empty(company)
print("You built a {0} {1} rocket from {2}.".format(name, model, company))
if __name__ == "__main__":
build_rocket("Falcon", 9, "SpaceX")
And here's how you can use assertions to unit test the above function:
.. code-block:: python
import unittest
from contracts import assertion
class RocketTests(unittest.TestCase):
def test_build_rocket(self):
assertion.does_not_raise(ValueError, build_rocket, "Falcon", 9, "SpaceX")
code-contracts officially supports Python 3.3 and onwards.
Simply run the following command in your favorite terminal:
.. code-block:: bash
$ pip install code-contracts
The full documentation is available at http://contracts.readthedocs.io/.
FAQs
A library that provides code contracts and assertions.
We found that code-contracts demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.