Multi-line examples can be tested + ALBERT patch for CircleCI

All tests should now work fine.
This commit is contained in:
Lysandre 2020-01-14 13:29:27 -05:00 committed by Lysandre Debut
parent 837577256b
commit 64abd3e0aa
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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]