<s> from __future__ import print_function <EOL> import json <EOL> from os import path , listdir <EOL> from unittest import TestCase <EOL> import six <EOL> from nose . tools import nottest <EOL> from jsontest import JsonTest <EOL> from pyinfra . cli import json_encode <EOL> from pyinfra . api . facts import FACTS <EOL> @ nottest <EOL> def make_fact_tests ( fact_name ) : <EOL> fact = FACTS [ fact_name ] ( ) <EOL> @ six . add_metaclass ( JsonTest ) <EOL> class TestTests ( TestCase ) : <EOL> jsontest_files = path . join ( '<STR_LIT>' , '<STR_LIT>' , fact_name ) <EOL> def jsontest_function ( self , test_name , test_data ) : <EOL> if '<STR_LIT>' in test_data : <EOL> fact . command ( test_data [ '<STR_LIT>' ] ) <EOL> data = fact . process ( test_data [ '<STR_LIT>' ] ) <EOL> data = json . loads ( json . dumps ( data , default = json_encode ) ) <EOL> try : <EOL> self . assertEqual ( data , test_data [ '<STR_LIT>' ] ) <EOL> except AssertionError as e : <EOL> print ( ) <EOL> print ( '<STR_LIT>' , json . dumps ( data , indent = <NUM_LIT:4> , default = json_encode ) ) <EOL> print ( '<STR_LIT>' , json . dumps ( <EOL> test_data [ '<STR_LIT>' ] , indent = <NUM_LIT:4> , default = json_encode <EOL> ) ) <EOL> raise e <EOL> TestTests . __name__ = '<STR_LIT>' . format ( fact_name ) <EOL> return TestTests <EOL> fact_tests = [ <EOL> filename <EOL> for filename in listdir ( path . join ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> if path . isdir ( path . join ( '<STR_LIT>' , '<STR_LIT>' , filename ) ) <EOL> ] <EOL> for fact_name in fact_tests : <EOL> locals ( ) [ fact_name ] = make_fact_tests ( fact_name ) </s>
