"vscode:/vscode.git/clone" did not exist on "358efb26b6d7576bc8179a37c190e5f916773b5e"
Commit 7e98e211 authored by Aymeric Augustin's avatar Aymeric Augustin
Browse files

Remove unittest.main() in test modules.

This construct isn't used anymore these days.

Running python tests/test_foo.py puts the tests/ directory on
PYTHONPATH, which isn't representative of how we run tests.

Use python -m unittest tests/test_foo.py instead.
parent 6be7cdda
...@@ -99,7 +99,3 @@ class TFAutoModelTest(unittest.TestCase): ...@@ -99,7 +99,3 @@ class TFAutoModelTest(unittest.TestCase):
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
model = TFAutoModelWithLMHead.from_pretrained(SMALL_MODEL_IDENTIFIER) model = TFAutoModelWithLMHead.from_pretrained(SMALL_MODEL_IDENTIFIER)
self.assertIsInstance(model, TFBertForMaskedLM) self.assertIsInstance(model, TFBertForMaskedLM)
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import BertConfig, is_tf_available from transformers import BertConfig, is_tf_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -315,7 +313,3 @@ class TFBertModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -315,7 +313,3 @@ class TFBertModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in ["bert-base-uncased"]: for model_name in ["bert-base-uncased"]:
model = TFBertModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFBertModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -378,7 +378,3 @@ def ids_tensor(shape, vocab_size, rng=None, name=None, dtype=None): ...@@ -378,7 +378,3 @@ def ids_tensor(shape, vocab_size, rng=None, name=None, dtype=None):
output = tf.constant(values, shape=shape, dtype=dtype if dtype is not None else tf.int32) output = tf.constant(values, shape=shape, dtype=dtype if dtype is not None else tf.int32)
return output return output
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import CTRLConfig, is_tf_available from transformers import CTRLConfig, is_tf_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -201,7 +199,3 @@ class TFCTRLModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -201,7 +199,3 @@ class TFCTRLModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in list(TF_CTRL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(TF_CTRL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = TFCTRLModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFCTRLModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import DistilBertConfig, is_tf_available from transformers import DistilBertConfig, is_tf_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -221,7 +219,3 @@ class TFDistilBertModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -221,7 +219,3 @@ class TFDistilBertModelTest(TFCommonTestCases.TFCommonModelTester):
# for model_name in list(DISTILBERT_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: # for model_name in list(DISTILBERT_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
# model = DistilBertModel.from_pretrained(model_name, cache_dir=CACHE_DIR) # model = DistilBertModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
# self.assertIsNotNone(model) # self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import GPT2Config, is_tf_available from transformers import GPT2Config, is_tf_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -234,7 +232,3 @@ class TFGPT2ModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -234,7 +232,3 @@ class TFGPT2ModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in list(TF_GPT2_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(TF_GPT2_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = TFGPT2Model.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFGPT2Model.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import OpenAIGPTConfig, is_tf_available from transformers import OpenAIGPTConfig, is_tf_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -235,7 +233,3 @@ class TFOpenAIGPTModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -235,7 +233,3 @@ class TFOpenAIGPTModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in list(TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(TF_OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = TFOpenAIGPTModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFOpenAIGPTModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -244,7 +244,3 @@ class TFRobertaModelIntegrationTest(unittest.TestCase): ...@@ -244,7 +244,3 @@ class TFRobertaModelIntegrationTest(unittest.TestCase):
self.assertEqual(list(output.numpy().shape), expected_shape) self.assertEqual(list(output.numpy().shape), expected_shape)
expected_tensor = tf.constant([[-0.9469, 0.3913, 0.5118]]) expected_tensor = tf.constant([[-0.9469, 0.3913, 0.5118]])
self.assertTrue(numpy.allclose(output.numpy(), expected_tensor.numpy(), atol=1e-3)) self.assertTrue(numpy.allclose(output.numpy(), expected_tensor.numpy(), atol=1e-3))
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import T5Config, is_tf_available from transformers import T5Config, is_tf_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -165,7 +163,3 @@ class TFT5ModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -165,7 +163,3 @@ class TFT5ModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in ["t5-small"]: for model_name in ["t5-small"]:
model = TFT5Model.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFT5Model.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import random import random
import unittest
from transformers import TransfoXLConfig, is_tf_available from transformers import TransfoXLConfig, is_tf_available
...@@ -207,7 +206,3 @@ class TFTransfoXLModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -207,7 +206,3 @@ class TFTransfoXLModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in list(TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(TF_TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = TFTransfoXLModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFTransfoXLModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import is_tf_available from transformers import is_tf_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -306,7 +304,3 @@ class TFXLMModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -306,7 +304,3 @@ class TFXLMModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in list(TF_XLM_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(TF_XLM_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = TFXLMModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFXLMModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import random import random
import unittest
from transformers import XLNetConfig, is_tf_available from transformers import XLNetConfig, is_tf_available
...@@ -401,7 +400,3 @@ class TFXLNetModelTest(TFCommonTestCases.TFCommonModelTester): ...@@ -401,7 +400,3 @@ class TFXLNetModelTest(TFCommonTestCases.TFCommonModelTester):
for model_name in list(TF_XLNET_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(TF_XLNET_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = TFXLNetModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TFXLNetModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import random import random
import unittest
from transformers import is_torch_available from transformers import is_torch_available
...@@ -208,7 +207,3 @@ class TransfoXLModelTest(CommonTestCases.CommonModelTester): ...@@ -208,7 +207,3 @@ class TransfoXLModelTest(CommonTestCases.CommonModelTester):
for model_name in list(TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(TRANSFO_XL_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = TransfoXLModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = TransfoXLModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -14,8 +14,6 @@ ...@@ -14,8 +14,6 @@
# limitations under the License. # limitations under the License.
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import unittest
from transformers import is_torch_available from transformers import is_torch_available
from .test_configuration_common import ConfigTester from .test_configuration_common import ConfigTester
...@@ -390,7 +388,3 @@ class XLMModelTest(CommonTestCases.CommonModelTester): ...@@ -390,7 +388,3 @@ class XLMModelTest(CommonTestCases.CommonModelTester):
for model_name in list(XLM_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(XLM_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = XLMModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = XLMModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
import random import random
import unittest
from transformers import is_torch_available from transformers import is_torch_available
...@@ -499,7 +498,3 @@ class XLNetModelTest(CommonTestCases.CommonModelTester): ...@@ -499,7 +498,3 @@ class XLNetModelTest(CommonTestCases.CommonModelTester):
for model_name in list(XLNET_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]: for model_name in list(XLNET_PRETRAINED_MODEL_ARCHIVE_MAP.keys())[:1]:
model = XLNetModel.from_pretrained(model_name, cache_dir=CACHE_DIR) model = XLNetModel.from_pretrained(model_name, cache_dir=CACHE_DIR)
self.assertIsNotNone(model) self.assertIsNotNone(model)
if __name__ == "__main__":
unittest.main()
...@@ -150,7 +150,3 @@ class ScheduleInitTest(unittest.TestCase): ...@@ -150,7 +150,3 @@ class ScheduleInitTest(unittest.TestCase):
) )
lrs_2 = unwrap_and_save_reload_schedule(scheduler, self.num_steps) lrs_2 = unwrap_and_save_reload_schedule(scheduler, self.num_steps)
self.assertListEqual([l[0] for l in lrs], [l[0] for l in lrs_2]) self.assertListEqual([l[0] for l in lrs], [l[0] for l in lrs_2])
if __name__ == "__main__":
unittest.main()
...@@ -83,7 +83,3 @@ class OptimizationFTest(unittest.TestCase): ...@@ -83,7 +83,3 @@ class OptimizationFTest(unittest.TestCase):
self.assertEqual(accumulator.step, 0) self.assertEqual(accumulator.step, 0)
self.assertListAlmostEqual(accumulator._gradients[0].values[0].value().numpy().tolist(), [0.0, 0.0], tol=1e-2) self.assertListAlmostEqual(accumulator._gradients[0].values[0].value().numpy().tolist(), [0.0, 0.0], tol=1e-2)
self.assertListAlmostEqual(accumulator._gradients[0].values[1].value().numpy().tolist(), [0.0, 0.0], tol=1e-2) self.assertListAlmostEqual(accumulator._gradients[0].values[1].value().numpy().tolist(), [0.0, 0.0], tol=1e-2)
if __name__ == "__main__":
unittest.main()
...@@ -205,7 +205,3 @@ class MultiColumnInputTestCase(unittest.TestCase): ...@@ -205,7 +205,3 @@ class MultiColumnInputTestCase(unittest.TestCase):
for tokenizer, model, config in TF_QA_FINETUNED_MODELS: for tokenizer, model, config in TF_QA_FINETUNED_MODELS:
nlp = pipeline(task="question-answering", model=model, config=config, tokenizer=tokenizer) nlp = pipeline(task="question-answering", model=model, config=config, tokenizer=tokenizer)
self._test_multicolumn_pipeline(nlp, valid_samples, invalid_samples, mandatory_output_keys) self._test_multicolumn_pipeline(nlp, valid_samples, invalid_samples, mandatory_output_keys)
if __name__ == "__main__":
unittest.main()
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
from __future__ import absolute_import, division, print_function, unicode_literals from __future__ import absolute_import, division, print_function, unicode_literals
import os import os
import unittest
from transformers.tokenization_albert import AlbertTokenizer from transformers.tokenization_albert import AlbertTokenizer
...@@ -78,7 +77,3 @@ class AlbertTokenizationTest(CommonTestCases.CommonTokenizerTester): ...@@ -78,7 +77,3 @@ class AlbertTokenizationTest(CommonTestCases.CommonTokenizerTester):
assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_2 + [ assert encoded_pair == [tokenizer.cls_token_id] + text + [tokenizer.sep_token_id] + text_2 + [
tokenizer.sep_token_id tokenizer.sep_token_id
] ]
if __name__ == "__main__":
unittest.main()
...@@ -49,7 +49,3 @@ class AutoTokenizerTest(unittest.TestCase): ...@@ -49,7 +49,3 @@ class AutoTokenizerTest(unittest.TestCase):
tokenizer = AutoTokenizer.from_pretrained(SMALL_MODEL_IDENTIFIER) tokenizer = AutoTokenizer.from_pretrained(SMALL_MODEL_IDENTIFIER)
self.assertIsInstance(tokenizer, BertTokenizer) self.assertIsInstance(tokenizer, BertTokenizer)
self.assertEqual(len(tokenizer), 12) self.assertEqual(len(tokenizer), 12)
if __name__ == "__main__":
unittest.main()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment