All Questions
Tagged with unit-testing python
207 questions
4
votes
3
answers
171
views
Function to calculate energy where all parameters must be positive
I have a function which requires all parameters to be positive:
...
5
votes
1
answer
364
views
Trying Out DDD : How to enforce data integrity and immutability
I've been transitioning from type-safe programming languages like Dart and Java to Python, and I'm trying to enforce Domain-Driven Design (DDD) principles in a language that naturally leans towards ...
3
votes
1
answer
98
views
Build a dictionary from a string by the extraction of data from all the pairs <TAG|VAL> contained inside the string and clean string from TAGs
I have written code to manage a string and retrieve from it a dictionary which must contain pairs key-value dependent from the string.
To be more clear I'll show ...
2
votes
2
answers
99
views
Goal: Writing Effective Unit Tests to Ensure a Datetime Conversion To/From Local-UTC Works
As the title lists, I am trying to write an effective unittest suite to ensure that the function that converts a date to UTC from local or vice-versa is doing as planned. But it seems hard because ...
1
vote
1
answer
81
views
Event manager based on decorators
This module is a simple event manager that works with decorators. I would like feedback on:
Bugs
Any ideas to get rid of the classevent decorator, which ...
5
votes
1
answer
200
views
Testing binary search module, based on bisect
The bisect module can only find the index to insert an element. I created a simple class based on the bisect module for precise searching and covered all the edge cases that came to mind with tests.
...
1
vote
1
answer
67
views
Testing code for An+B microsyntax parsing library
I have a small package that provides some API for playing around with the <An+B> CSS microsyntax. It is 100% type hinted and tested, but doesn't actually have any real/useful features and this ...
6
votes
3
answers
2k
views
Python strong password validator ( with unit test )
Lately, I was studying the concept of unit testing in python, so I have decided to write a imperative strong password validator ( checker ) and also attach a unit test to it.
I would like to know if ...
2
votes
1
answer
271
views
Test suite for population-count function, using random input
For the purpose of this discussion, I have the following function:
...
1
vote
1
answer
157
views
Change unit-test structure to avoid try/except/finally clause
I have 10 or 20 tests with the same structure which I would like to improve. The test itself is nested within a try/except/finally clause to make sure that some of ...
4
votes
3
answers
376
views
Money class in python
I have recently created the Money class with a helper class Currency. What do you think about the following code? I created unit ...
0
votes
0
answers
88
views
Generate INSERTs from function parameters with jinja2
I'm writing unit-tests with pytest for sqlite database and reporting functions and I need to arrange them by inserting minimal ...
4
votes
2
answers
2k
views
Clean up directories and files when a unit test fails
While running unit tests (most of them integration tests) with Python I create some directories. They need to be deleted after the test or when the test fails. The execution of the cleanup code need ...
4
votes
1
answer
198
views
Python unit tests for storing and loading objects
I wrote some code and thought I may get better with some feedback. I program for almost 5 years, mainly in python.
I care most about the unit testing.
I am not really sure, how industry standard unit ...
1
vote
0
answers
58
views
UPDATE on Newspaper Bill Calculator CLI with Python (3 of 3, Database)
Code is posted after explanation.
Due to the size of the project, this is being posted in three separate posts. This also ensures each post is more focused.
Post 1 of 3, Core: UPDATE 1 on Newspaper ...