How to use test_override method in autotest

Best Python code snippet using autotest_python

test_expose_headers.py

Source:test_expose_headers.py Github

copy

Full Screen

...16 def test_default():17 return 'Welcome!'18 @self.app.route('/test_override')19 @cross_origin(expose_headers=["X-My-Custom-Header", "X-Another-Custom-Header"])20 def test_override():21 return 'Welcome!'22 def test_default(self):23 for resp in self.iter_responses('/test_default', origin='www.example.com'):24 self.assertTrue(resp.headers.get(ACL_EXPOSE_HEADERS) is None,25 "No Access-Control-Expose-Headers by default")26 def test_override(self):27 ''' The specified headers should be returned in the ACL_EXPOSE_HEADERS28 and correctly serialized if it is a list.29 '''30 for resp in self.iter_responses('/test_override', origin='www.example.com'):31 self.assertEqual(resp.headers.get(ACL_EXPOSE_HEADERS),32 'X-Another-Custom-Header, X-My-Custom-Header')33class AppConfigExposeHeadersTestCase(AppConfigTest, ExposeHeadersTestCase):34 def __init__(self, *args, **kwargs):35 super(AppConfigExposeHeadersTestCase, self).__init__(*args, **kwargs)36 def test_default(self):37 @self.app.route('/test_default')38 @cross_origin()39 def test_default():40 return 'Welcome!'41 super(AppConfigExposeHeadersTestCase, self).test_default()42 def test_override(self):43 self.app.config['CORS_EXPOSE_HEADERS'] = ["X-My-Custom-Header",44 "X-Another-Custom-Header"]45 @self.app.route('/test_override')46 @cross_origin()47 def test_override():48 return 'Welcome!'49 super(AppConfigExposeHeadersTestCase, self).test_override()50if __name__ == "__main__":...

Full Screen

Full Screen

utils.py

Source:utils.py Github

copy

Full Screen

1from omegaconf import DictConfig, OmegaConf2from os import path3from typing import Optional, Union4__DIR__ = path.dirname(path.realpath(__file__))5class Config:6 config: DictConfig7 def reset_config(config: Optional[Union[str, DictConfig]] = None) -> None:8 if config is None: config = path.join(__DIR__, "config.yaml")9 Config.raw_config = OmegaConf.load(config) if isinstance(config, str) else config10 Config.config = Config.raw_config11 def resolve_config(as_dict:bool = False, test_override:Optional[str] = None) -> None:12 Config.config = Config.resolve(Config.raw_config,13 as_dict=as_dict,14 test_override=test_override)15 def resolve(16 subconfig: Optional[Union[dict, DictConfig]] = None,17 as_dict: bool = False,18 test_override: Optional[str] = None19 ) -> Union[dict, DictConfig]:20 subconfig = (Config.raw_config if subconfig is None else subconfig).copy()21 if (test_override is not None) and (test_override in subconfig):22 subconfig.update(subconfig[test_override])23 data_dir = path.relpath(Config.raw_config.data_dir.format(__dir__=__DIR__))24 for k, v in subconfig.items():25 if k.startswith("."): # hidden keys26 del subconfig[k]27 elif k.endswith("_subdir"):28 subconfig[f"{k[:-7]}_dir"] = path.join(data_dir, v)29 del subconfig[k]30 elif isinstance(v, DictConfig) or isinstance(v, dict):31 subconfig[k] = Config.resolve(v, as_dict=as_dict, test_override=test_override)32 return OmegaConf.to_object(subconfig) if as_dict else subconfig...

Full Screen

Full Screen

test_parse_command_line_args.py

Source:test_parse_command_line_args.py Github

copy

Full Screen

1""" unit tests for parse_command_line_args"""2import pytest3from covid19_graphs.command_line_script import parse_command_line_args4def test_supply_output_dir():5 """Tests supplied out_dir is set"""6 args = parse_command_line_args(test_override=['output_dir'])7 assert args.out_dir == 'output_dir'8def script_help_message(capsys):9 """Gets the script's -h help message"""10 with pytest.raises(SystemExit):11 parse_command_line_args(test_override=['-h'])12 return capsys.readouterr().out13def test_with_empty_args_raises_error():14 """ User passes no arguments15 This is invalid as they have to specify at least one input file/seq16 """17 with pytest.raises(SystemExit):18 parse_command_line_args(test_override=[])19def test_with_invalid_option_raises_error():20 """ User passes a string and -invalid_option.21 This must raise SystemExit.22 """23 with pytest.raises(SystemExit):24 parse_command_line_args(test_override=['A', '-invalid'])25def test_supply_2_strings_raises_error():26 """User passes 2 strings"""27 with pytest.raises(SystemExit):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful