From 64abd3e0aab07180aeabcef2ca80586ab54d64c3 Mon Sep 17 00:00:00 2001 From: Lysandre Date: Tue, 14 Jan 2020 13:29:27 -0500 Subject: [PATCH] Multi-line examples can be tested + ALBERT patch for CircleCI All tests should now work fine. --- src/transformers/configuration_albert.py | 3 ++- tests/test_examples.py | 7 +++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/transformers/configuration_albert.py b/src/transformers/configuration_albert.py index 2e8211f442..859475b0e9 100644 --- a/src/transformers/configuration_albert.py +++ b/src/transformers/configuration_albert.py @@ -79,6 +79,7 @@ class AlbertConfig(PretrainedConfig): Example:: + from transformers import AlbertConfig, AlbertModel # Initializing an ALBERT-xxlarge style configuration albert_xxlarge_configuration = AlbertConfig() @@ -90,7 +91,7 @@ class AlbertConfig(PretrainedConfig): ) # Initializing a model from the ALBERT-base style configuration - model = AlbertModel(bert_base_configuration) + model = AlbertModel(albert_xxlarge_configuration) # Accessing the model configuration configuration = model.config diff --git a/tests/test_examples.py b/tests/test_examples.py index b9e49a07b3..ee0167b552 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest import os +import unittest def get_examples_from_file(file): @@ -37,7 +37,7 @@ def get_examples_from_file(file): example_mode = True example_indentation = line.lower().find("example::") - return examples + return ['\n'.join(example) for example in examples] class TestCodeExamples(unittest.TestCase): @@ -51,8 +51,7 @@ class TestCodeExamples(unittest.TestCase): print("Testing", configuration_file, str(len(examples)) + "/" + str(len(examples))) def execute_example(code_example): - for line in code_example: - exec(line) + exec(code_example) with self.subTest(msg=configuration_file): [execute_example(code_example) for code_example in examples]