ImportError: cannot import name ‘url_quote’ from ‘werkzeug.urls’

I had the same problem. It is because Werkzeug 3.0.0 was released and Flask doesn’t specify the dependency correctly (requirements says Werkzeug>=2.2.0). This is why, Werkzeug 3.0.0 is still installed and Flask 2.2.2 isn’t made for Werkzeug 3.0.0. Solution: Just set a fix version for Werkzeug such as Werkzeug==2.2.2 in your requirements.txt and it should … Read more

How to pass a parameter to a fixture function in Pytest?

This is actually supported natively in py.test via indirect parametrization. In your case, you would have: @pytest.fixture def tester(request): “””Create tester object””” return MyTester(request.param) class TestIt: @pytest.mark.parametrize(‘tester’, [[‘var1’, ‘var2’]], indirect=True) def test_tc1(self, tester): tester.dothis() assert 1

Specify which pytest tests to run from a file

You can use -k option to run test cases with different patterns: py.test tests_directory/foo.py tests_directory/bar.py -k ‘test_001 or test_some_other_test’ This will run test cases with name test_001 and test_some_other_test deselecting the rest of the test cases. Note: This will select any test case starting with test_001 or test_some_other_test. For example, if you have test case … Read more

How do I properly assert that an exception gets raised in pytest?

pytest.raises(Exception) is what you need. Code import pytest def test_passes(): with pytest.raises(Exception) as e_info: x = 1 / 0 def test_passes_without_info(): with pytest.raises(Exception): x = 1 / 0 def test_fails(): with pytest.raises(Exception) as e_info: x = 1 / 1 def test_fails_without_info(): with pytest.raises(Exception): x = 1 / 1 # Don’t do this. Assertions are caught … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)