Questions tagged [conftest]

56 questions
1
vote
0 answers

Running pytest.main in python code always returns value of None when argument is clearly set

This is the test file that i am running. # this file is test_define.py import pytest def test_it(aw_name): print(aw_name) if __name__ == '__main__': pytest.main(['-s', 'v', '--aw_name', 'boom', 'test_define.py']) This is the conftest…
jagusking
  • 11
  • 2
1
vote
0 answers

Creating a custom section in a pytest report with specific instruction for failed tests in a certain module

I'm already aware of the stackoverflow answer describing how to set-up a new section with a general message for all tests, but I would like to have a special section to only show up if a test from a certain module fails. The story behind this is…
Philipp
  • 11
  • 1
1
vote
1 answer

Conftest verify fixture data

I have been writing a few policies using Conftest and wish to verify my configuration with the conftest verify command. So far I have been able to successfully verify my policies like so test_deployment_with_security_context { no_violations with…
tomasbasham
  • 1,695
  • 2
  • 18
  • 37
1
vote
1 answer

IDE doesn't recognize conftest.py as a python file

I have a python project with tests and a conftest file, and a few days ago - out of nowhere - Pycharm decided that it's not a python script: The result is that I can't debug it, can't jump to source, don't have inspection and ext'. Moreover - If I…
omer mazig
  • 965
  • 2
  • 10
  • 17
1
vote
0 answers

How do I get a single test to run in VSCode the same way it does on the command line?

I'm using Visual Studio Code 1.39.2 and PyTest 6 with Python 3.8. I have this pytest.ini file [pytest] addopts = --docker-compose=./tests/docker-compose.yml --docker-compose-remove-volumes env_override_existing_values = 1 env_files = …
Dave
  • 15,639
  • 133
  • 442
  • 830
1
vote
1 answer

How to pass arguments from 'conftest,py' to test file (pytest)?

How to pass arguments from conftest.py to test file ? conftest.py import sys,pytest def tear_down(): print("teardown") def pytest_addoption(parser): parser.addoption("--a1", action="store", default="some_default_value", help="provide…
StackGuru
  • 471
  • 1
  • 9
  • 25
0
votes
0 answers

[Selenium][Python][Driver Config]: Unable to use the option.add_argument on conftest.py

conftest.py import pytest from selenium import webdriver from selenium.webdriver.chrome.service import Service as CH from selenium.webdriver.edge.service import Service as EG from webdriver_manager.chrome import ChromeDriverManager from…
Hazeya
  • 1
0
votes
0 answers

How can I capture the video of selenium automation test on failure with data driven UI automation framework using pytest?

Here, I will be running my selenium automation test with pytest framework and using data driven approach. that means there is only function in testcase file. Note: service_name is a variable which is containing service_name from data file and and it…
0
votes
1 answer

Have a object created on a fixture accassible at setup_class, teardown_class, setup_method, and teardown_method

I have a conftest.py: import pytest import asyncio from some_library import MyLibrary @pytest.fixture() def event_loop(request): loop = asyncio.get_event_loop_policy().new_event_loop() yield loop loop.close() …
CFlux
  • 346
  • 4
  • 9
0
votes
1 answer

conftest verify is unexpectedly passing

Running conftest verify resulted in a pass even though the rule should have failed at db.storage_encrypted != true. What am I missing here? # deny.rego deny_unencrypted[msg] { db := input.resource.aws_db_instance[x] db.storage_encrypted != true…
Gerald
  • 567
  • 1
  • 10
  • 17
0
votes
0 answers

pytest and conftest.py arguments NameError: name 'params' is not defined

I'm trying to pass some variables via command line to a pytest script to run with selenium. I can't figure out how to insert the "profile" variable, unfortunately I'm a goat in python. This is my conftest.py def pytest_addoption(parser): …
eliafino
  • 96
  • 8
0
votes
2 answers

Can PyTest addoption be made global variables across all files?

I am trying to make user input from pytest addoption to be accessible through all files I have a conftest.py file with code import pytest def pytest_addoption(parser): try: parser.addoption('--user', action='store', default='',…
coder_g
  • 5
  • 2
0
votes
3 answers

How to ignore FAIL during conftest policy check in atlantis

I am still in the testing phase and would like to allow merging of my PR even if the policy_check is FAIlING. What flag I can pass to enable that ? My current config: repos: - id: /.*/ workflow: custom apply_requirements: [mergeable] …
chan214
  • 21
  • 1
0
votes
1 answer

Pytest fixture command line returning function object instead of value

I am trying to take a command line input for testing. Instead of returning the input as a string, python fixture is returning a function object My contest.py file has this code: def pytest_addoption(parser): parser.addoption('--n',…
coder_g
  • 5
  • 2
0
votes
1 answer

Error loading conftest.py due to missing field "lineno" from alias

I have a python/flask application with a test suite. When I run coverage run -m pytest -s tests I get the following error: ImportError while loading conftest '/Users/abc/Documents/server/app/tests/conftest.py TypeError: required field "lineno"…
sage76
  • 1
  • 4