@@ -664,10 +664,22 @@ def pytest_configure(config):
664664 assert "Environment" in html
665665 assert len (re .findall (content , html )) == 1
666666
667- def test_environment_list_value (self , testdir ):
668- content = tuple (str (random .random ()) for i in range (10 ))
669- content += tuple (random .random () for i in range (10 ))
670- expected_content = ", " .join (str (i ) for i in content )
667+ _unsorted_tuples = [
668+ ("Hello" , "fzWZP6vKRv" , "hello" , "garAge" , "123Go" ),
669+ (2 , 4 , 2 , 1 , 54 ),
670+ ("Yes" , 400 , "5.4" ),
671+ ]
672+ _sorted_tuples = [
673+ "123Go, Hello, fzWZP6vKRv, garAge, hello" ,
674+ "1, 2, 2, 4, 54" ,
675+ "400, 5.4, Yes" ,
676+ ]
677+ _test_environment_list_value_data_set = zip (_unsorted_tuples , _sorted_tuples )
678+
679+ @pytest .mark .parametrize (
680+ "content,expected_content" , _test_environment_list_value_data_set
681+ )
682+ def test_environment_list_value (self , testdir , content , expected_content ):
671683 expected_html_re = fr"<td>content</td>\n\s+<td>{ expected_content } </td>"
672684 testdir .makeconftest (
673685 f"""
@@ -682,6 +694,46 @@ def pytest_configure(config):
682694 assert "Environment" in html
683695 assert len (re .findall (expected_html_re , html )) == 1
684696
697+ _unordered_dict = {k : len (k ) for k in _unsorted_tuples [0 ]}
698+ _unordered_dict_expected = (
699+ r'<td>content</td>\n\s+<td>{"123Go": 5, "Hello": 5, '
700+ r'"fzWZP6vKRv": 10, "garAge": 6, "hello": 5}</td>'
701+ )
702+ _unordered_dict_with_html = {
703+ "First Link" : r'<a href="https://www.w3schools.com">W3Schools</a>' ,
704+ "Second Link" : r'<a href="https://www.w3schools.com">W2Schools</a>' ,
705+ "Third Link" : r'<a href="https://www.w3schools.com">W4Schools</a>' ,
706+ }
707+ _unordered_dict_with_html_expected = (
708+ r"<td>content</td>\n\s+<td>{"
709+ r'"First Link": "<a href=\\"https://www.w3schools.com\\">W3Schools</a>", '
710+ r'"Second Link": "<a href=\\"https://www.w3schools.com\\">W2Schools</a>", '
711+ r'"Third Link": "<a href=\\"https://www.w3schools.com\\">W4Schools</a>"}</td>'
712+ )
713+
714+ @pytest .mark .parametrize (
715+ "unordered_dict,expected_output" ,
716+ [
717+ (_unordered_dict , _unordered_dict_expected ),
718+ (_unordered_dict_with_html , _unordered_dict_with_html_expected ),
719+ ],
720+ )
721+ def test_environment_unordered_dict_value (
722+ self , testdir , unordered_dict , expected_output
723+ ):
724+ testdir .makeconftest (
725+ f"""
726+ def pytest_configure(config):
727+ values = dict({ json .dumps (unordered_dict )} )
728+ config._metadata['content'] = values
729+ """
730+ )
731+ testdir .makepyfile ("def test_pass(): pass" )
732+ result , html = run (testdir )
733+ assert result .ret == 0
734+ assert "Environment" in html
735+ assert len (re .findall (expected_output , html )) == 1
736+
685737 def test_environment_ordered (self , testdir ):
686738 testdir .makeconftest (
687739 """
0 commit comments