py.test does not find tests under a class

I am trying to create test classes that aren't unittest based. This method under this class class ClassUnderTestTests: def test_something(self): cannot be detected and run when you call...

py.test to test flask register, AssertionError: Popped wrong request context

I'm using flask to do register and login: from flask.ext.security.views import register, login class Register(Resource): def post(self): return register() class Login(Resource): ...

patching a class yields "AttributeError: Mock object has no attribute" when accessing instance attributes

The Problem Using mock.patch with autospec=True to patch a class is not preserving attributes of instances of that class. The Details I am trying to test a class Bar that instantiates an instance...

'pytest' exits with no error, but with "collected 0 items"

I have been trying to run unit tests using pytest in Python. I had written a module with one class and some methods inside that class. I wrote a unit test for this module (with a simple assert...

How to parametrize a Pytest fixture

Consider the following Pytest: import pytest class TimeLine(object): instances = [0, 1, 2] @pytest.fixture def timeline(): return TimeLine() def test_timeline(timeline): for instance in...

Python - InvocationError in tox running py.test and coverage test

My project has the following structure: my_project | setup.py tox.ini src | core_functions.py client.py server.py sql_database.py tests.py The tests.py file contains the...

Python test fixture to run a single test?

I'm looking for something like ruby rspec's focus metadata or elixir's mix tags to run a single python test. Ruby RSpec Example: # $ rspec spec it 'runs a single test', :focus do expect(2).to...

pytest: selective log levels on a per-module basis

I'm using pytest-3.7.1 which has good support for logging, including live logging to stdout during tests. I'm using --log-cli-level=DEBUG to dump all debug-level logging to the console as it...

conda list vs pip list differences in conda created environment

I am using conda version 4.5.11, python 3.6.6, and Windows 10. I create a virtual environment using conda conda create --name venv When I check for installed packages conda list it is (as...

Can I retry for failed tests in Pytest

Can I ask for failed tests in pytest Some number of restarts (retries). For example: if 2 attempts fail and the third succeeds, then the total result succeeds

Python: why do I get an error when I import geopandas?

I try to import geopandas in my jupyter notebook. import geopandas as gp and I get the following error: ImportError:...

using the same Dockerfile to build images with different python version

I have a python script that I'd want to run on 2 different containers running python 2.7 and python 3.6. I want to use the same docker file to build 2 different images, with the difference being...

Cloning private github repository within organisation in actions

I have 2 private GitHub repositories (say A and B) in the organization (say ORG). Repository A has repository B in requirements.txt: -e [email protected]:ORG/B.git#egg=B And I have the...

Pytest stuck on 'collecting...'

I have a file new_script_piped.py with a function I want to test: def columns_preparation(df): df.COLUMN_1.replace({'-999':'don't consider'}, inplace=True) ...more lines return...

How can I use pip cache in github actions?

I am having some issues with using cached pip in Github Actions. My workflow setup is name: tests on: [push, pull_request] jobs: linux: runs-on: ubuntu-18.04 strategy: ...

Is there a way to tell pytest which tests to run based on a marker attribute value?

I have a test separated by a version using markers: Example: @pytest.mark.version("1.0") def test_does_something(): assert 1 @pytest.mark.version("1.0.1") def test_does_another_thing(): ...

Unit Test Retry functionality provided by Python

I am using the code below to perform exponential retries. I have set the reties to 5. As part of my unit test, I am mocking the response and returning status code 503. However I do not see 5...

Getting following errors buliding registration form using html5 and css.Getting following errors

Getting following errors buliding registration form using html5 and css. Registraion form with input type fields,one dropdown list and button. Getting following errors buliding registration form...

marking a test as xfail with double parameterize in pytest

I have a pytest test that tests several inputs against two different databases. i do it with using the parameterized mark twice: @pytest.mark.parametrize( "input_type", [ ...

Unable to connect to postgres database from django while running pytest

Django project and postgres are in different docker containers. I want to write the unit test cases for this application using pytest. I have implemented test cases using APIClient() along with...

dockerpy not able to connect to docker daemon inside bit bucket container

I have the below simple script which is basically to test whether https://github.com/docker/docker-py is able to run commands inside bitbucket containers: import docker CLIENT =...

How to mock subprocess.run in pytest?

I have this class defined: class InternalProc: @staticmethod def get_data(): try: result = subprocess.run(['bridge-client', '--business-credentials'], ...

How to disable pytest xdist only when pytest is called with filters?

When I run all pytests I do want to fully benefit from spreading the load on all m cores (xdist) but when I run a subset of them is almost always for development/debugging purposes, case in which...

How to set up and tear down a database between tests in FastAPI?

I have set up my unit tests as per FastAPI documentation, but it only covers a case where database is persisted among tests. What if I want to build and tear down database per test? (for example,...

poetry install different package version based on extras

Using python-poetry, I would like to install different package versions based on the extras that I pass during the installation. E.g. I would like to # when extra == 'a', install numpy == 1.20.0 $...

How can I get torch-geometric to work using Nix?

I am trying to get the Python package torch-geometric to work using Nix (I am on NixOS). Currently, I use mach-nix to try and setup a Python environment. However, the difficulty is that some of...

Flask testing with pytest, ENV is set to production?

I have built a flask app and i would like to create a test suite. Reading around it looks like pytest is the way to go; however, I am finding it very difficult to understand how to get going, I...

BROWNIE - installation issue

I am trying to install Brownie and get the following error " PS C:\Python39> pip install eth-brownie Collecting eth-brownie Using cached eth_brownie-1.14.6-py3-none-any.whl (207 kB) ...

Trying to click on Metamask Login Button and Nothing Happens - Selenium Python

I want to create a scraping program on the PvU site https://marketplace.plantvsundead.com/#/login I've managed to open Chrome with the Metamask extension and to log in to metamask. Now I need to...

PIP failed to build package cytoolz

I'm trying to install eth-brownie using 'pipx install eth-brownie' but I get an error saying pip failed to build package: cytoolz Some possibly relevant errors from pip install: ...