Use this file to discover Exa products, pricing, evaluations, comparisons, use cases, agent interfaces, and technical documentation before exploring further.
Python testing libraries run automated checks against code, from a single function to a full acceptance scenario. A test runner discovers test functions or scenarios, runs them, and reports each failed assertion. These libraries let developers catch regressions before code reaches production.
Popularity
pytest has the most monthly downloads in this comparison, at 977.1M.
from hypothesis import given, strategies as st
@given(st.lists(st.integers()))
def test_sorted_length(values):
assert len(sorted(values)) == len(values)
test_sorted_length()
def _draw_body_media_type(draw: st.DrawFn, operation: APIOperation, parameter: OpenApiBody) -> str:
# Parameter may have a wildcard media type. In this case, choose any supported one try:
possible_media_types = sorted(
operation.schema.transport.get_matching_media_types(parameter.media_type), key=lambda x: x[0]
)
except MalformedMediaType as exc:
raise InvalidSchema.from_malformed_media_type(
exc, parameter.media_type, path=operation.path, method=operation.method
) from exc
if not possible_media_types:
all_media_types = operation.schema.get_request_payload_content_types(operation)
if all(
operation.schema.transport.get_first_matching_media_type(media_type) is None
for media_type in all_media_types
):
# No media type of this operation is supported raise SerializationNotPossible.from_media_types(*all_media_types) from None
# Other media types are possible - avoid choosing this media type in the future event_text = f"Can't serialize data to `{parameter.media_type}`."
note(f"{event_text} {SERIALIZERS_SUGGESTION_MESSAGE}")
event(event_text)
reject()
media_type, _ = draw(st.sampled_from(possible_media_types))
return media_type
from robot.api import TestSuite
suite = TestSuite("Example")
test = suite.tests.create("Values match")
test.body.create_keyword("Should Be Equal", args=["hello", "hello"])
result = suite.run()
def end_keyword(self, name, attributes): # pylint: disable=W0613
"""Listener method for keyword end.
:param name: keyword name
:param attributes: keyword attributes
If `name` exists in the protected keywords list then log level is
restored back to level it was before settings to NONE.
"""
if not self._is_robot_running():
return
normalized = self._normalize(name)
if self.stack and self.stack[-1][0] == normalized:
_, old = self.stack.pop()
BuiltIn().set_log_level(old)
# Run-on-failure if normalized != self.muted_keyword:
return
self.logger.debug("Un-muting failures after keyword: %s", name)
for library, _ in self.muted_optionals:
previous = self.muted_previous.get(library.__class__.__name__)
if previous:
library.register_keyword_to_run_on_failure(previous)
self.muted_keyword = None
self.muted_previous = {}
import unittest
from ddt import ddt, data
@ddt
class PositiveTests(unittest.TestCase):
@data(1, 2, 3)
def test_positive(self, value):
self.assertGreater(value, 0)
if __name__ == "__main__":
unittest.main()
FAQ
pytest suits most projects, with composable fixtures and parameterized cases. Hypothesis adds generated inputs and shrinks failing cases. Robot Framework and behave suit keyword-driven and behavior-driven acceptance tests.
Robot Framework runs keyword-driven acceptance tests and automation tasks, with Python libraries exposed as reusable keywords. It stores execution results in XML or JSON.
unittest provides class-based test cases and fixture lifecycles. pytest provides composable fixtures and declared argument combinations. Its fixtures cannot pass directly into unittest TestCase methods.
The pytest-xdist plugin distributes pytest test execution across workers. Pabot runs Robot Framework suites in separate processes.
Hypothesis generates test inputs from strategies and reduces failing cases to simpler examples. Its tests run through pytest.
For coding agents
Found your testing library? Help your agent use it.
Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.