Esempio n. 1
0
def create_test_group_result(stdout,
                             stderr,
                             run_time,
                             extra_info,
                             timeout=None):
    """
    Return the arguments passed to this function in a dictionary. If stderr is
    falsy, change it to None. Load the json string in stdout as a dictionary.
    """
    test_results, malformed = loads_partial_json(stdout, dict)
    return {
        "time": run_time,
        "timeout": timeout,
        "tests": test_results,
        "stderr": stderr or None,
        "malformed": stdout if malformed else None,
        "extra_info": extra_info or {},
    }
 def test_well_formed_partial_single_type_dict(self):
     """ Parses partially well formed json getting only dict types """
     j = 'bad bit{"a": ["b", "c"]} other bad bit'
     result, malformed = sm.loads_partial_json(j, dict)
     assert result == [{"a": ["b", "c"]}]
     assert malformed
 def test_well_formed_partial_single_type_list(self):
     """ Parses partially well formed json getting only list types """
     j = 'bad bit["b", "c"] other bad bit'
     result, malformed = sm.loads_partial_json(j, list)
     assert result == [["b", "c"]]
     assert malformed
 def test_well_formed_partial_any(self):
     """ Parses partially well formed json """
     j = 'bad bit{"a": ["b", "c"]} other bad bit'
     result, malformed = sm.loads_partial_json(j)
     assert result == [{"a": ["b", "c"]}]
     assert malformed
 def test_nothing_well_formed(self):
     """ Parses a json without any well formed json """
     j = "just a string"
     result, malformed = sm.loads_partial_json(j)
     assert result == []
     assert malformed
 def test_well_formed_single_type_list(self):
     """ Parses well formed json getting only list types """
     j = '["b", "c"]'
     result, malformed = sm.loads_partial_json(j, list)
     assert result == [["b", "c"]]
     assert not malformed
 def test_well_formed_single_type_dict(self):
     """ Parses well formed json getting only dict types """
     j = '{"a": ["b", "c"]}'
     result, malformed = sm.loads_partial_json(j, dict)
     assert result == [{"a": ["b", "c"]}]
     assert not malformed
 def test_well_formed_any(self):
     """ Parses well formed json """
     j = '{"a": ["b", "c"]}'
     result, malformed = sm.loads_partial_json(j)
     assert result == [{"a": ["b", "c"]}]
     assert not malformed