Skip to content

Commit 279f2c0

Browse files
committed
python3Packages.nltk: run tests
1 parent acc6352 commit 279f2c0

File tree

1 file changed

+62
-7
lines changed

1 file changed

+62
-7
lines changed

pkgs/development/python-modules/nltk/default.nix

Lines changed: 62 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@
88
joblib,
99
regex,
1010
tqdm,
11+
12+
# preInstallCheck
13+
nltk,
14+
15+
# nativeCheckInputs
16+
matplotlib,
17+
numpy,
18+
pyparsing,
19+
pytestCheckHook,
20+
pytest-mock,
1121
}:
1222

1323
buildPythonPackage rec {
@@ -29,13 +39,58 @@ buildPythonPackage rec {
2939
tqdm
3040
];
3141

32-
# Tests require some data, the downloading of which is impure. It would
33-
# probably make sense to make the data another derivation, but then feeding
34-
# that into the tests (given that we need nltk itself to download the data,
35-
# unless there's an easy way to download it without nltk's downloader) might
36-
# be complicated. For now let's just disable the tests and hope for the
37-
# best.
38-
doCheck = false;
42+
# Use new passthru function to pass dependencies required for testing
43+
preInstallCheck = ''
44+
export NLTK_DATA=${
45+
nltk.dataDir (
46+
d: with d; [
47+
averaged-perceptron-tagger-eng
48+
averaged-perceptron-tagger-rus
49+
brown
50+
cess-cat
51+
cess-esp
52+
conll2007
53+
floresta
54+
gutenberg
55+
inaugural
56+
indian
57+
large-grammars
58+
nombank-1-0
59+
omw-1-4
60+
pl196x
61+
porter-test
62+
ptb
63+
punkt-tab
64+
rte
65+
sinica-treebank
66+
stopwords
67+
tagsets-json
68+
treebank
69+
twitter-samples
70+
udhr
71+
universal-tagset
72+
wmt15-eval
73+
wordnet
74+
wordnet-ic
75+
words
76+
]
77+
)
78+
}
79+
'';
80+
81+
nativeCheckInputs = [
82+
pytestCheckHook
83+
matplotlib
84+
numpy
85+
pyparsing
86+
pytest-mock
87+
88+
pkgs.which
89+
];
90+
91+
disabledTestPaths = [
92+
"nltk/test/unit/test_downloader.py" # Touches network
93+
];
3994

4095
pythonImportsCheck = [ "nltk" ];
4196

0 commit comments

Comments
 (0)