How to use _load_schema method in unittest-xml-reporting

Best Python code snippet using unittest-xml-reporting_python

__init__.py

Source:__init__.py Github

copy

Full Screen

...9import yaml10import rapidjson11from bigchaindb.common.exceptions import SchemaValidationError12logger = logging.getLogger(__name__)13def _load_schema(name, path=__file__):14 """Load a schema from disk"""15 path = os.path.join(os.path.dirname(path), name + '.yaml')16 with open(path) as handle:17 schema = yaml.safe_load(handle)18 fast_schema = rapidjson.Validator(rapidjson.dumps(schema))19 return path, (schema, fast_schema)20TX_SCHEMA_VERSION = 'v2.0'21TX_SCHEMA_PATH, TX_SCHEMA_COMMON = _load_schema('transaction_' +22 TX_SCHEMA_VERSION)23_, TX_SCHEMA_CREATE = _load_schema('transaction_create_' +24 TX_SCHEMA_VERSION)25_, TX_SCHEMA_TRANSFER = _load_schema('transaction_transfer_' +26 TX_SCHEMA_VERSION)27_, TX_SCHEMA_VALIDATOR_ELECTION = _load_schema('transaction_validator_election_' +28 TX_SCHEMA_VERSION)29_, TX_SCHEMA_CHAIN_MIGRATION_ELECTION = _load_schema('transaction_chain_migration_election_' +30 TX_SCHEMA_VERSION)31_, TX_SCHEMA_VOTE = _load_schema('transaction_vote_' + TX_SCHEMA_VERSION)32def _validate_schema(schema, body):33 """Validate data against a schema"""34 # Note35 #36 # Schema validation is currently the major CPU bottleneck of37 # BigchainDB. the `jsonschema` library validates python data structures38 # directly and produces nice error messages, but validation takes 4+ ms39 # per transaction which is pretty slow. The rapidjson library validates40 # much faster at 1.5ms, however it produces _very_ poor error messages.41 # For this reason we use both, rapidjson as an optimistic pathway and42 # jsonschema as a fallback in case there is a failure, so we can produce43 # a helpful error message.44 try:45 schema[1](rapidjson.dumps(body))...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run unittest-xml-reporting automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful