Skip to content
This repository was archived by the owner on Dec 16, 2022. It is now read-only.

Commit dcba726

Browse files
authored
WIP: Skip tests that require Java in test-install (#1551)
* Skip java tests in test-install * CD to the parent directory in test_install. This addresses a regression introduced in #1418. * Exit with the same exit code as pytest.
1 parent 8438f91 commit dcba726

File tree

6 files changed

+18
-8
lines changed

6 files changed

+18
-8
lines changed

allennlp/commands/test_install.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ def _get_module_root():
5252

5353
def _run_test(args: argparse.Namespace):
5454
initial_working_dir = os.getcwd()
55-
module_root = _get_module_root()
56-
logger.info("Changing directory to %s", module_root)
57-
os.chdir(module_root)
58-
test_dir = os.path.join(module_root, "tests")
55+
module_parent = _get_module_root().parent
56+
logger.info("Changing directory to %s", module_parent)
57+
os.chdir(module_parent)
58+
test_dir = os.path.join(module_parent, "allennlp")
5959
logger.info("Running tests at %s", test_dir)
6060
if args.run_all:
6161
# TODO(nfliu): remove this when notebooks have been rewritten as markdown.
62-
pytest.main([test_dir, '-k', 'not notebooks_test'])
62+
exit_code = pytest.main([test_dir, '--color=no', '-k', 'not notebooks_test'])
6363
else:
64-
pytest.main([test_dir, '-k', 'not sniff_test and not notebooks_test'])
64+
exit_code = pytest.main([test_dir, '--color=no', '-k', 'not sniff_test and not notebooks_test',
65+
'-m', 'not java'])
6566
# Change back to original working directory after running tests
6667
os.chdir(initial_working_dir)
68+
exit(exit_code)

allennlp/tests/models/semantic_parsing/wikitables/wikitables_erm_semantic_parser_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
# pylint: disable=no-self-use
22
import os
3+
import pytest
34

45
from allennlp.common.testing import ModelTestCase
56
from allennlp.training.metrics.wikitables_accuracy import SEMPRE_ABBREVIATIONS_PATH, SEMPRE_GRAMMAR_PATH
67

8+
@pytest.mark.java
79
class WikiTablesErmSemanticParserTest(ModelTestCase):
810
def setUp(self):
911
self.should_remove_sempre_abbreviations = not os.path.exists(SEMPRE_ABBREVIATIONS_PATH)

allennlp/tests/models/semantic_parsing/wikitables/wikitables_mml_semantic_parser_test.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# pylint: disable=invalid-name,no-self-use,protected-access
22
from collections import namedtuple
33
import os
4+
import pytest
45

56
from flaky import flaky
67
from numpy.testing import assert_almost_equal
@@ -11,6 +12,7 @@
1112
from allennlp.models import Model, WikiTablesMmlSemanticParser
1213
from allennlp.training.metrics.wikitables_accuracy import SEMPRE_ABBREVIATIONS_PATH, SEMPRE_GRAMMAR_PATH
1314

15+
@pytest.mark.java
1416
class WikiTablesMmlSemanticParserTest(ModelTestCase):
1517
def setUp(self):
1618
self.should_remove_sempre_abbreviations = not os.path.exists(SEMPRE_ABBREVIATIONS_PATH)

allennlp/tests/predictors/wikitables_parser_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# pylint: disable=no-self-use,invalid-name
22
import os
3+
import pytest
34

45
from allennlp.common.testing import AllenNlpTestCase
56
from allennlp.models.archival import load_archive
67
from allennlp.predictors import Predictor
78
from allennlp.predictors.wikitables_parser import (SEMPRE_ABBREVIATIONS_PATH, SEMPRE_GRAMMAR_PATH)
89

9-
10+
@pytest.mark.java
1011
class TestWikiTablesParserPredictor(AllenNlpTestCase):
1112
def setUp(self):
1213
super().setUp()

allennlp/tests/training/metrics/wikitables_accuracy_test.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# pylint: disable=no-self-use,invalid-name,protected-access
22
import os
3+
import pytest
34

45
from allennlp.common.testing import AllenNlpTestCase
56
from allennlp.training.metrics import WikiTablesAccuracy
67
from allennlp.training.metrics.wikitables_accuracy import SEMPRE_ABBREVIATIONS_PATH, SEMPRE_GRAMMAR_PATH
78

8-
9+
@pytest.mark.java
910
class WikiTablesAccuracyTest(AllenNlpTestCase):
1011
def setUp(self):
1112
super().setUp()

pytest.ini

+2
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
testpaths = allennlp/tests/
33
log_format = %(asctime)s - %(levelname)s - %(name)s - %(message)s
44
log_level = DEBUG
5+
markers =
6+
java

0 commit comments

Comments
 (0)