File: json_validation.py

package info (click to toggle)
libgnatcoll 18-4
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,068 kB
  • sloc: ada: 40,393; python: 354; ansic: 310; makefile: 245; sh: 31
file content (22 lines) | stat: -rw-r--r-- 679 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from e3.testsuite.result import TestStatus
from drivers.data_validation import DataValidationDriver
import os
import json
import logging


class JSONValidationDriver(DataValidationDriver):

    def validate_result(self, process, data_file, result):
        # Read data file
        with open(os.path.join(self.test_env['test_dir'], data_file)) as fd:
            expected = json.load(fd)

        got = json.loads(process.out)
        if got != expected:
            logging.debug('%s\n<=>\n%s', got, expected)
            result.set_status(TestStatus.FAIL)
            self.push_result(result)
            return TestStatus.FAIL
        else:
            return TestStatus.PASS