allennlp.common.testing

Utilities and helpers for writing tests.

class allennlp.common.testing.test_case.AllenNlpTestCase(methodName='runTest')[source]

Bases: unittest.case.TestCase

A custom subclass of TestCase that disables some of the more verbose AllenNLP logging and that creates and destroys a temp directory as a test fixture.

setUp()[source]
tearDown()[source]
class allennlp.common.testing.model_test_case.ModelTestCase(methodName='runTest')[source]

Bases: allennlp.common.testing.test_case.AllenNlpTestCase

A subclass of AllenNlpTestCase with added methods for testing Model subclasses.

static assert_fields_equal(field1, field2, tolerance: float = 1e-06, name: str = None) → None[source]
ensure_batch_predictions_are_consistent()[source]
ensure_model_can_train_save_and_load(param_file: str)[source]
set_up_model(param_file, dataset_file)[source]