How to use _get_envconfigs method in tox

Best Python code snippet using tox_python

test_config.py

Source:test_config.py Github

copy

Full Screen

...828 env = config.envconfigs['py24']829 assert env.basepython == "python2.4"830 assert env.commands == [['xyz']]831class TestHashseedOption:832 def _get_envconfigs(self, newconfig, args=None, tox_ini=None,833 make_hashseed=None):834 if args is None:835 args = []836 if tox_ini is None:837 tox_ini = """838 [testenv]839 """840 if make_hashseed is None:841 make_hashseed = lambda: '123456789'842 original_make_hashseed = tox._config.make_hashseed843 tox._config.make_hashseed = make_hashseed844 try:845 config = newconfig(args, tox_ini)846 finally:847 tox._config.make_hashseed = original_make_hashseed848 return config.envconfigs849 def _get_envconfig(self, newconfig, args=None, tox_ini=None):850 envconfigs = self._get_envconfigs(newconfig, args=args,851 tox_ini=tox_ini)852 return envconfigs["python"]853 def _check_hashseed(self, envconfig, expected):854 assert envconfig.setenv == {'PYTHONHASHSEED': expected}855 def _check_testenv(self, newconfig, expected, args=None, tox_ini=None):856 envconfig = self._get_envconfig(newconfig, args=args, tox_ini=tox_ini)857 self._check_hashseed(envconfig, expected)858 def test_default(self, tmpdir, newconfig):859 self._check_testenv(newconfig, '123456789')860 def test_passing_integer(self, tmpdir, newconfig):861 args = ['--hashseed', '1']862 self._check_testenv(newconfig, '1', args=args)863 def test_passing_string(self, tmpdir, newconfig):864 args = ['--hashseed', 'random']865 self._check_testenv(newconfig, 'random', args=args)866 def test_passing_empty_string(self, tmpdir, newconfig):867 args = ['--hashseed', '']868 self._check_testenv(newconfig, '', args=args)869 @pytest.mark.xfail(sys.version_info >= (3,2),870 reason="at least Debian python 3.2/3.3 have a bug: "871 "http://bugs.python.org/issue11884")872 def test_passing_no_argument(self, tmpdir, newconfig):873 """Test that passing no arguments to --hashseed is not allowed."""874 args = ['--hashseed']875 try:876 self._check_testenv(newconfig, '', args=args)877 except SystemExit:878 e = sys.exc_info()[1]879 assert e.code == 2880 return881 assert False # getting here means we failed the test.882 def test_setenv(self, tmpdir, newconfig):883 """Check that setenv takes precedence."""884 tox_ini = """885 [testenv]886 setenv =887 PYTHONHASHSEED = 2888 """889 self._check_testenv(newconfig, '2', tox_ini=tox_ini)890 args = ['--hashseed', '1']891 self._check_testenv(newconfig, '2', args=args, tox_ini=tox_ini)892 def test_noset(self, tmpdir, newconfig):893 args = ['--hashseed', 'noset']894 envconfig = self._get_envconfig(newconfig, args=args)895 assert envconfig.setenv is None896 def test_noset_with_setenv(self, tmpdir, newconfig):897 tox_ini = """898 [testenv]899 setenv =900 PYTHONHASHSEED = 2901 """902 args = ['--hashseed', 'noset']903 self._check_testenv(newconfig, '2', args=args, tox_ini=tox_ini)904 def test_one_random_hashseed(self, tmpdir, newconfig):905 """Check that different testenvs use the same random seed."""906 tox_ini = """907 [testenv:hash1]908 [testenv:hash2]909 """910 next_seed = [1000]911 # This function is guaranteed to generate a different value each time.912 def make_hashseed():913 next_seed[0] += 1914 return str(next_seed[0])915 # Check that make_hashseed() works.916 assert make_hashseed() == '1001'917 envconfigs = self._get_envconfigs(newconfig, tox_ini=tox_ini,918 make_hashseed=make_hashseed)919 self._check_hashseed(envconfigs["hash1"], '1002')920 # Check that hash2's value is not '1003', for example.921 self._check_hashseed(envconfigs["hash2"], '1002')922 def test_setenv_in_one_testenv(self, tmpdir, newconfig):923 """Check using setenv in one of multiple testenvs."""924 tox_ini = """925 [testenv:hash1]926 setenv =927 PYTHONHASHSEED = 2928 [testenv:hash2]929 """930 envconfigs = self._get_envconfigs(newconfig, tox_ini=tox_ini)931 self._check_hashseed(envconfigs["hash1"], '2')932 self._check_hashseed(envconfigs["hash2"], '123456789')933class TestIndexServer:934 def test_indexserver(self, tmpdir, newconfig):935 config = newconfig("""936 [tox]937 indexserver =938 name1 = XYZ939 name2 = ABC940 """)941 assert config.indexserver['default'].url == None942 assert config.indexserver['name1'].url == "XYZ"943 assert config.indexserver['name2'].url == "ABC"944 def test_parse_indexserver(self, newconfig):...

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 tox 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