Skip to content
Snippets Groups Projects
Commit 37faa8a1 authored by Luis Araujo's avatar Luis Araujo
Browse files

Keep the test case data format private in the module


Keep the test case data format private in the parser module.

Signed-off-by: default avatarLuis Araujo <luis.araujo@collabora.co.uk>
parent c78e403e
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ import shutil ...@@ -10,7 +10,7 @@ import shutil
from jinja2 import Environment, FileSystemLoader from jinja2 import Environment, FileSystemLoader
from argparse import ArgumentParser from argparse import ArgumentParser
from parser import parse_format, test_case_format from parser import parse_format
TEMPLATE_DIR="." TEMPLATE_DIR="."
...@@ -143,7 +143,7 @@ def generate_test_case(tc_file, directory): ...@@ -143,7 +143,7 @@ def generate_test_case(tc_file, directory):
# Parse file to detect any syntax error. # Parse file to detect any syntax error.
print("Parsing file", tc_file) print("Parsing file", tc_file)
parse_format(tc_data, test_case_format) parse_format(tc_data)
env = Environment(loader=FileSystemLoader([TEMPLATE_DIR])) env = Environment(loader=FileSystemLoader([TEMPLATE_DIR]))
# Get template from environment and render it. # Get template from environment and render it.
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
import sys import sys
import yaml import yaml
# This structure defines the test case YAML file format.
test_case_format = { test_case_format = {
'metadata' : (True, { 'metadata' : (True, {
'name' : (True, ""), 'name' : (True, ""),
...@@ -35,7 +35,7 @@ test_case_format = { ...@@ -35,7 +35,7 @@ test_case_format = {
'parse' : (False, {}) 'parse' : (False, {})
} }
def parse_format(test_case, test_case_format): def _parse_format(test_case, test_case_format):
for tagf, valuestr in test_case_format.items(): for tagf, valuestr in test_case_format.items():
mandatory, valuef = valuestr mandatory, valuef = valuestr
value = test_case.get(tagf) value = test_case.get(tagf)
...@@ -63,14 +63,17 @@ def parse_format(test_case, test_case_format): ...@@ -63,14 +63,17 @@ def parse_format(test_case, test_case_format):
sys.exit(1) sys.exit(1)
if type(value) == dict: if type(value) == dict:
parse_format(value, valuef) _parse_format(value, valuef)
return True return True
def parse_format(test_case):
return _parse_format(test_case, test_case_format)
if '__main__' == __name__: if '__main__' == __name__:
testcase = sys.argv[1] testcase = sys.argv[1]
with open(testcase) as test_case: with open(testcase) as test_case:
test_case_data = yaml.safe_load(test_case) test_case_data = yaml.safe_load(test_case)
parse_format(test_case_data, test_case_format) parse_format(test_case_data)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment