pytest

Override Standard Assert Messaging in Pytest Assert

喜你入骨 提交于 2021-02-11 06:55:03
问题 I'm using Pytest to test some SQL queries my team runs programmatically over time. My SQL queries are lists of JSONs - one JSON corresponds to one row of data. I've got a function that diffs the JSON key:value pairs so that we can point to exactly which values are different for a given row. Ideally, I'd output a list of these diffs instead of the standard output of an assert statement, which ends up looking clunky and not-very-useful for the end user. 回答1: Pytest give us the hook pytest

Azure Self hosted agent to run pytest

匆匆过客 提交于 2021-02-10 20:17:22
问题 I have installed a self-hosted agent on my local VM, it's connected to azure no issues there. I have a python code on azure DevOps I have installed all the requirements.txt requirements manually into the cmd line of the local VM so that self-hosted agent installed on it doesn't have to install them ( to minimize the build & deployment time) But when I have below code in the YAML file to run pytest cases pipeline is failing because of below error This is my Yaml file trigger: - master

Azure Self hosted agent to run pytest

浪子不回头ぞ 提交于 2021-02-10 20:15:57
问题 I have installed a self-hosted agent on my local VM, it's connected to azure no issues there. I have a python code on azure DevOps I have installed all the requirements.txt requirements manually into the cmd line of the local VM so that self-hosted agent installed on it doesn't have to install them ( to minimize the build & deployment time) But when I have below code in the YAML file to run pytest cases pipeline is failing because of below error This is my Yaml file trigger: - master

Parametrize pytest fixture

為{幸葍}努か 提交于 2021-02-10 12:42:41
问题 As far as I understood from the documentation about pytest fixture parameterization - it creates copies of the fixture with the given params and thus calls each test which requires this fixture with this different copies. My needs are a little bit different. Suppose there is a fixture: @pytest.fixture def sample_foo(): return Foo(file_path='file/path/test.json') def test1(sample_foo): pass def test2(sample_foo): pass The problem is that test test1 and test2 require the same instance of class

Parametrize pytest fixture

大兔子大兔子 提交于 2021-02-10 12:40:58
问题 As far as I understood from the documentation about pytest fixture parameterization - it creates copies of the fixture with the given params and thus calls each test which requires this fixture with this different copies. My needs are a little bit different. Suppose there is a fixture: @pytest.fixture def sample_foo(): return Foo(file_path='file/path/test.json') def test1(sample_foo): pass def test2(sample_foo): pass The problem is that test test1 and test2 require the same instance of class

Can arbirary configuration for tests be set in pytest.ini?

房东的猫 提交于 2021-02-10 07:45:45
问题 I want to centralize configuration for my tests and it seems like pytest.ini would be the place but im having trouble finding an example/feature for this. For example I have a directory with files my tests might need called "test_resources". this is my structure: ├── pytest.ini ├── myproject │ └── someFunctionsOne │ ├── one.py │ └── two.py └── tests ├── integration │ └── someFunctionsOneTestblah.py ├── test_resources │ ├── sample-data.json │ └── test-data-blahablahb.csv └── unit └──

Can arbirary configuration for tests be set in pytest.ini?

北战南征 提交于 2021-02-10 07:45:13
问题 I want to centralize configuration for my tests and it seems like pytest.ini would be the place but im having trouble finding an example/feature for this. For example I have a directory with files my tests might need called "test_resources". this is my structure: ├── pytest.ini ├── myproject │ └── someFunctionsOne │ ├── one.py │ └── two.py └── tests ├── integration │ └── someFunctionsOneTestblah.py ├── test_resources │ ├── sample-data.json │ └── test-data-blahablahb.csv └── unit └──

How to not mark Jenkins job as FAILURE when pytest tests fail

你离开我真会死。 提交于 2021-02-10 06:09:04
问题 I have a Jenkins setup with a pipeline that uses pytest to run some test suites. Sometimes a test fails and sometimes the test environment crashes (random HTTP timeout, external lib error, etc.). The job parses the XML test result but the build is marked as FAILURE as long as pytest returns non-zero. I want Jenkins to get exit code zero from pytest even if there are failed tests but I also want other errors to be marked as failures. Are there any pytest options that can fix this? I found

How to not mark Jenkins job as FAILURE when pytest tests fail

旧时模样 提交于 2021-02-10 06:07:15
问题 I have a Jenkins setup with a pipeline that uses pytest to run some test suites. Sometimes a test fails and sometimes the test environment crashes (random HTTP timeout, external lib error, etc.). The job parses the XML test result but the build is marked as FAILURE as long as pytest returns non-zero. I want Jenkins to get exit code zero from pytest even if there are failed tests but I also want other errors to be marked as failures. Are there any pytest options that can fix this? I found

How to not mark Jenkins job as FAILURE when pytest tests fail

此生再无相见时 提交于 2021-02-10 06:04:28
问题 I have a Jenkins setup with a pipeline that uses pytest to run some test suites. Sometimes a test fails and sometimes the test environment crashes (random HTTP timeout, external lib error, etc.). The job parses the XML test result but the build is marked as FAILURE as long as pytest returns non-zero. I want Jenkins to get exit code zero from pytest even if there are failed tests but I also want other errors to be marked as failures. Are there any pytest options that can fix this? I found