Category "python-unittest"

Python unit test cannot find module [duplicate]

I have a question about how to correctly import module in python unit test module. this is my directory structure project - | _ Libra

Mock patch specific instance of class

How to mock a specific instance of a class using patch? In my test file I have: @classmethod def setUpClass(cls): cls.instance_of_my_class = myClass() one

PyCharm: individually working tests, not finding a file when run in group

In my Python project, I have a set of unittests, that load some data from files in a data sub-directory. In PyCharm (Community 2019.3), running each of them in

How to mock an environment variable that is referenced in an imported module?

I have created a file containing environment variables and I am writing a test for this file. The file ("my_variables.py") looks like: import os if os.getenv("

Python3.6 error: ModuleNotFoundError: No module named 'src'

I know similar questions have been asked before... But I had a quick doubt... I have been following this link: https://www.python-course.eu/python3_packages.php

Unit Testing Django Model Save Function

I'm creating tests to check that a custom calibration model save function updates an asset record (foreign key) if it is the latest calibration record for the a

Simulate the click on a button in the PyQt5 QMessageBox widget, during unittest CI

Rather than a long speech, if we run the minimum example below: $ python3 Python 3.7.6 (default, Jan 30 2020, 09:44:41) [GCC 9.2.1 20190827 (Red Hat 9.2.1-1)]

Why cant unittest.TestCases see my py.test fixtures?

I'm trying to use py.test's fixtures with my unit tests, in conjunction with unittest. I've put several fixtures in a conftest.py file at the top level of the p

Insufficient output from unittest subTest elements under pytest

I'm interested in using unittest's subTest for looping through some very similar tests. I found that, when I run tests written in this way under pytest (or nos