@@ -695,26 +695,44 @@ def pytest_configure(config):
695
695
assert len (re .findall (expected_html_re , html )) == 1 , html
696
696
697
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
+ )
698
713
699
- @pytest .mark .parametrize ("unordered_dict" , [_unordered_dict ])
700
- def test_environment_unordered_dict_value (self , testdir , unordered_dict ):
701
- expected_html_re = (
702
- r"<td>content</td>\n\s+<td>{'123Go': 5, 'Hello': 5, "
703
- r"'fzWZP6vKRv': 10, 'garAge': 6, 'hello': 5}</td>"
704
- )
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
+ ):
705
724
testdir .makeconftest (
706
- """
725
+ f """
707
726
def pytest_configure(config):
708
- values = dict({'Hello': 5, 'fzWZP6vKRv': 10, 'garAge': 6, 'hello': 5,
709
- '123Go': 5})
727
+ values = dict({ json .dumps (unordered_dict )} )
710
728
config._metadata['content'] = values
711
729
"""
712
730
)
713
731
testdir .makepyfile ("def test_pass(): pass" )
714
732
result , html = run (testdir )
715
733
assert result .ret == 0
716
734
assert "Environment" in html
717
- assert len (re .findall (expected_html_re , html )) == 1 , html
735
+ assert len (re .findall (expected_output , html )) == 1 , html
718
736
719
737
def test_environment_ordered (self , testdir ):
720
738
testdir .makeconftest (
0 commit comments