@@ -218,6 +218,18 @@ def mode(self, axis, numeric_only):
218
218
"""
219
219
pass
220
220
221
+ def good_import (self ):
222
+ """
223
+ Ensure import other than numpy and pandas are fine.
224
+
225
+ Examples
226
+ --------
227
+ This example does not import pandas or import numpy.
228
+ >>> import time
229
+ >>> import datetime
230
+ """
231
+ pass
232
+
221
233
222
234
class BadGenericDocStrings (object ):
223
235
"""Everything here has a bad docstring
@@ -504,14 +516,27 @@ def no_punctuation(self):
504
516
505
517
class BadExamples (object ):
506
518
507
- def npPd_import (self ):
519
+ def numpy_import (self ):
520
+ """
521
+ Provide example with numpy import.
522
+
523
+ Examples
524
+ --------
525
+ This example does not import pandas.
526
+ >>> import numpy as np
527
+ >>> import datetime
528
+ """
529
+ pass
530
+
531
+ def pandas_import (self ):
508
532
"""
509
- Provide example with numpy and pandas import
533
+ Provide example with pandas import.
510
534
511
535
Examples
512
536
--------
513
- import numpy as np
514
- import pandas as pd
537
+ This example does not import numpy.
538
+ >>> import pandas as pd
539
+ >>> import pickle
515
540
"""
516
541
pass
517
542
@@ -615,10 +640,11 @@ def test_bad_generic_functions(self, func):
615
640
marks = pytest .mark .xfail ),
616
641
pytest .param ('BadReturns' , 'no_punctuation' , ('foo' ,),
617
642
marks = pytest .mark .xfail ),
618
- # Examples
619
- ('BadExamples' , 'npPd_import' ,
620
- ('Examples should not have `import pandas as pd` ' ,
621
- 'Examples should not have `import numpy as np` ' ,))
643
+ # Examples tests
644
+ ('BadExamples' , 'numpy_import' ,
645
+ ('Examples should not have `import numpy` ' ,)),
646
+ ('BadExamples' , 'pandas_import' ,
647
+ ('Examples should not have `import pandas` ' ,))
622
648
])
623
649
def test_bad_examples (self , capsys , klass , func , msgs ):
624
650
result = validate_one (self ._import_path (klass = klass , func = func )) # noqa:F821
0 commit comments