Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Fluent API for assertions supporting pytest with focus on developer experience.
This project aims to provide a fluent API for assertions supporting pytest, designed with simplicity and ease of use in mind.
The core idea is to make writing assertions more intuitive, readable, and enjoyable by offering a fluent interface that leverages the power of modern Python typing. It aims to be easy to use in any IDE for enhanced developer productivity.
⚠️ Current Status This project is in its early exploratory phase. While the core functionality is present, it is not yet fully mature. Use with caution as the API may evolve rapidly and changes could be breaking.
Classes:
from fluent_assertions import assert_that
def test_class():
@dataclasses.dataclass
class User:
name: str
age: int
def get_name(self):
return self.name
list_of_users = [User(name="Guenther", age=51), User(name="Jack", age=12)]
(
assert_that(list_of_users)
.has_size(2)
.extracting(User.get_name)
.contains_exactly(["Guenther", "Jack"])
.last()
.is_equal_to("Jack")
)
Dictionaries:
def test_dict():
example_dict = {
"name": "Guenther",
"age": "51",
}
(
assert_that(example_dict)
.is_not_empty()
.contains_keys(["name", "age"])
.contains_values(["Guenther", "51"])
)
Lists:
def test_list():
(
assert_that([1, 2, 3])
.contains_only(1, 2, 3)
.has_size(3)
.contains_subsequence([2, 3])
)
Available on PyPi:
pip install fluent-assertions
Feedback and collaboration are highly encouraged! If you encounter bugs, have feature requests, or want to contribute improvements, feel free to open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
FAQs
Fluent API for assertions supporting pytest with focus on developer experience.
We found that fluent-assertions 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.