Remove unused PyTypeFromUsedAttributesHelper and its tests
[idea/community.git] / python / testSrc / com / jetbrains / python / PythonCompletionTest.java
1 /*
2  * Copyright 2000-2013 JetBrains s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.jetbrains.python;
17
18 import com.google.common.collect.Lists;
19 import com.intellij.codeInsight.completion.CompletionType;
20 import com.intellij.codeInsight.completion.impl.CamelHumpMatcher;
21 import com.intellij.codeInsight.lookup.AutoCompletionPolicy;
22 import com.intellij.codeInsight.lookup.Lookup;
23 import com.intellij.codeInsight.lookup.LookupElement;
24 import com.intellij.codeInsight.lookup.LookupElementBuilder;
25 import com.intellij.testFramework.PsiTestUtil;
26 import com.jetbrains.python.documentation.DocStringFormat;
27 import com.jetbrains.python.documentation.PyDocumentationSettings;
28 import com.jetbrains.python.fixtures.PyTestCase;
29 import com.jetbrains.python.psi.LanguageLevel;
30 import org.jetbrains.annotations.Nullable;
31
32 import java.util.Arrays;
33 import java.util.HashSet;
34 import java.util.List;
35
36 public class PythonCompletionTest extends PyTestCase {
37
38   private void doTest() {
39     CamelHumpMatcher.forceStartMatching(getTestRootDisposable());
40     final String testName = "completion/" + getTestName(true);
41     myFixture.configureByFile(testName + ".py");
42     myFixture.completeBasic();
43     myFixture.checkResultByFile(testName + ".after.py");
44   }
45
46   private void doMultiFileTest() {
47     myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
48     myFixture.configureByFile("a.py");
49     myFixture.completeBasic();
50     myFixture.checkResultByFile("completion/" + getTestName(true) + "/a.after.py");
51   }
52
53   private List<String> doTestByText(String text) {
54     myFixture.configureByText(PythonFileType.INSTANCE, text);
55     myFixture.completeBasic();
56     return myFixture.getLookupElementStrings();
57   }
58
59   @Nullable
60   private List<String> doTestByFile() {
61     myFixture.configureByFile("completion/" + getTestName(true) + ".py");
62     myFixture.completeBasic();
63     return myFixture.getLookupElementStrings();
64   }
65
66   @Nullable
67   private List<String> doTestSmartByFile() {
68     myFixture.configureByFile("completion/" + getTestName(true) + ".py");
69     myFixture.complete(CompletionType.SMART);
70     return myFixture.getLookupElementStrings();
71   }
72
73   public void testLocalVar() {
74     doTest();
75   }
76
77   public void testSelfMethod() {
78     doTest();
79   }
80
81   public void testSelfField() {
82     doTest();
83   }
84
85   public void testFuncParams() {
86     doTest();
87   }
88
89   public void testFuncParamsStar() {
90     doTest();
91   }
92
93   public void testInitParams() {
94     doTest();
95   }
96
97   public void testSuperInitParams() {      // PY-505
98     doTest();
99   }
100
101   public void testSuperInitKwParams() {      // PY-778
102     doTest();
103   }
104
105   public void testPredefinedMethodName() {
106     doTest();
107   }
108
109   public void testPredefinedMethodNot() {
110     doTest();
111   }
112
113   public void testClassPrivate() {
114     doTest();
115   }
116
117   public void testClassPrivateNotInherited() {
118     doTest();
119   }
120
121   public void testClassPrivateNotPublic() {
122     doTest();
123   }
124
125   public void testTwoUnderscores() {
126     doTest();
127   }
128
129   public void testOneUnderscore() {
130     final String testName = "completion/" + getTestName(true);
131     myFixture.configureByFile(testName + ".py");
132     myFixture.completeBasic();
133     myFixture.type('\n');
134     myFixture.checkResultByFile(testName + ".after.py");
135   }
136
137   public void testKwParamsInCodeUsage() { //PY-1002
138     doTest();
139   }
140
141   public void testKwParamsInCodeGetUsage() { //PY-1002
142     doTest();
143   }
144
145   public void testSuperInitKwParamsNotOnlySelfAndKwArgs() { //PY-1050
146     doTest();
147   }
148
149   public void testSuperInitKwParamsNoCompletion() {
150     doTest();
151   }
152
153   public void testIsInstance() {
154     doTest();
155   }
156
157   public void testIsInstanceAssert() {
158     doTest();
159   }
160
161   public void testIsInstanceTuple() {
162     doTest();
163   }
164
165   public void testPropertyParens() {  // PY-1037
166     doTest();
167   }
168
169   public void testClassNameFromVarName() {
170     doTest();
171   }
172
173   public void testClassNameFromVarNameChained() {  // PY-5629
174     doTest();
175   }
176
177   public void testPropertyType() {
178     doTest();
179   }
180
181   public void testSeenMembers() {  // PY-1181
182     final String testName = "completion/" + getTestName(true);
183     myFixture.configureByFile(testName + ".py");
184     final LookupElement[] elements = myFixture.completeBasic();
185     assertNotNull(elements);
186     assertEquals(1, elements.length);
187     assertEquals("children", elements[0].getLookupString());
188   }
189
190   public void testImportModule() {
191     final String testName = "completion/" + getTestName(true);
192     myFixture.configureByFiles(testName + ".py", "completion/someModule.py");
193     myFixture.completeBasic();
194     myFixture.checkResultByFile(testName + ".after.py");
195   }
196
197   public void testPy255() {
198     final String dirname = "completion/";
199     final String testName = dirname + "moduleClass";
200     myFixture.configureByFiles(testName + ".py", dirname + "__init__.py");
201     myFixture.copyDirectoryToProject(dirname + "mymodule", dirname + "mymodule");
202     myFixture.completeBasic();
203     myFixture.checkResultByFile(testName + ".after.py");
204   }
205
206   public void testPy874() {
207     final String dirname = "completion/";
208     final String testName = dirname + "py874";
209     myFixture.configureByFile(testName + ".py");
210     myFixture.copyDirectoryToProject(dirname + "root", dirname + "root");
211     myFixture.completeBasic();
212     myFixture.checkResultByFile(testName + ".after.py");
213   }
214
215   public void testClassMethod() {  // PY-833
216     doTest();
217   }
218
219   public void testStarImport() {
220     myFixture.configureByFiles("completion/starImport/starImport.py", "completion/starImport/importSource.py");
221     myFixture.completeBasic();
222     assertSameElements(myFixture.getLookupElementStrings(), Arrays.asList("my_foo", "my_bar"));
223   }
224
225   public void testSlots() {  // PY-1211
226     doTest();
227   }
228
229   public void testReturnType() {
230     doTest();
231   }
232
233   public void testWithType() { // PY-4198
234     setLanguageLevel(LanguageLevel.PYTHON26);
235     doTest();
236   }
237
238   public void testChainedCall() {  // PY-1565
239     doTest();
240   }
241
242   public void testFromImportBinary() {
243     myFixture.copyFileToProject("completion/root/binary_mod.pyd");
244     myFixture.copyFileToProject("completion/root/binary_mod.so");
245     myFixture.configureByFiles("completion/fromImportBinary.py", "completion/root/__init__.py");
246     myFixture.completeBasic();
247     myFixture.checkResultByFile("completion/fromImportBinary.after.py");
248   }
249
250   public void testNonExistingProperty() {  // PY-1748
251     doTest();
252   }
253
254   public void testImportItself() {  // PY-1895
255     myFixture.copyDirectoryToProject("completion/importItself/package1", "package1");
256     myFixture.configureFromTempProjectFile("package1/submodule1.py");
257     myFixture.completeBasic();
258     myFixture.checkResultByFile("completion/importItself.after.py");
259   }
260
261   public void testImportedFile() { // PY-1955
262     final String dirname = "completion/";
263     myFixture.copyDirectoryToProject(dirname + "root", dirname + "root");
264     myFixture.configureByFile(dirname + "importedFile.py");
265     myFixture.completeBasic();
266     myFixture.checkResultByFile(dirname + "importedFile.after.py");
267   }
268
269   public void testImportedModule() {  // PY-1956
270     final String dirname = "completion/";
271     myFixture.copyDirectoryToProject(dirname + "root", dirname + "root");
272     myFixture.configureByFile(dirname + "importedModule.py");
273     myFixture.completeBasic();
274     myFixture.checkResultByFile(dirname + "importedModule.after.py");
275   }
276
277   public void testDictKeys() {  // PY-2245
278     doTest();
279   }
280
281   public void testDictKeys2() { //PY-4181
282     doTest();
283   }
284
285   public void testDictKeys3() { //PY-5546
286     doTest();
287   }
288
289   public void testNoParensForDecorator() {  // PY-2210
290     doTest();
291   }
292
293   public void testSuperMethod() {  // PY-170
294     doTest();
295   }
296
297   public void testLocalVarInDictKey() {  // PY-2558
298     doTest();
299   }
300
301   public void testDictKeyPrefix() {
302     doTest();
303   }
304
305   public void testDictKeyPrefix2() {      //PY-3683
306     doTest();
307   }
308
309   public void testNoIdentifiersInImport() {
310     doTest();
311   }
312
313   public void testSuperClassAttributes() {
314     doTest();
315   }
316
317   public void testSuperClassAttributesNoCompletionInFunc() {
318     doTest();
319   }
320
321   public void testRelativeImport() {  // PY-2816
322     myFixture.copyDirectoryToProject("completion/relativeImport", "relativeImport");
323     myFixture.configureByFile("relativeImport/pkg/main.py");
324     myFixture.completeBasic();
325     myFixture.checkResultByFile("completion/relativeImport/pkg/main.after.py");
326   }
327
328   public void testRelativeImportNameFromInitPy() {  // PY-2816
329     myFixture.copyDirectoryToProject("completion/relativeImport", "relativeImport");
330     myFixture.configureByFile("relativeImport/pkg/name.py");
331     myFixture.completeBasic();
332     myFixture.checkResultByFile("completion/relativeImport/pkg/name.after.py");
333   }
334
335   public void testImport() {
336     doTest();
337   }
338
339   public void testDuplicateImportKeyword() {  // PY-3034
340     doMultiFileTest();
341   }
342
343   public void testImportInMiddleOfHierarchy() {  // PY-3016
344     doMultiFileTest();
345   }
346
347   public void testVeryPrivate() {  // PY-3246
348     doTest();
349   }
350
351   public void testReexportModules() {  // PY-2385
352     doMultiFileTest();
353   }
354
355   public void testModuleDotPy() {  // PY-5813
356     doMultiFileTest();
357   }
358
359   public void testHasAttr() {  // PY-4423
360     doTest();
361   }
362
363   public void testEpydocParamTag() {
364     final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
365     settings.setFormat(DocStringFormat.EPYTEXT);
366     try {
367       doTest();
368     }
369     finally {
370       settings.setFormat(DocStringFormat.PLAIN);
371     }
372   }
373
374   public void testEpydocTags() {
375     final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
376     settings.setFormat(DocStringFormat.EPYTEXT);
377     try {
378       myFixture.configureByFile("completion/epydocTags.py");
379       myFixture.completeBasic();
380       final List<String> lookupElementStrings = myFixture.getLookupElementStrings();
381       assertNotNull(lookupElementStrings);
382       assertTrue(lookupElementStrings.contains("@param"));
383     }
384     finally {
385       settings.setFormat(DocStringFormat.PLAIN);
386     }
387   }
388
389   public void testEpydocTagsMiddle() {
390     final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
391     settings.setFormat(DocStringFormat.EPYTEXT);
392     try {
393       myFixture.configureByFile("completion/epydocTagsMiddle.py");
394       myFixture.completeBasic();
395       myFixture.checkResultByFile("completion/epydocTagsMiddle.after.py");
396     }
397     finally {
398       settings.setFormat(DocStringFormat.PLAIN);
399     }
400   }
401
402   public void testIdentifiersInPlainDocstring() {
403     final PyDocumentationSettings settings = PyDocumentationSettings.getInstance(myFixture.getModule());
404     settings.setFormat(DocStringFormat.PLAIN);
405     myFixture.configureByFile("completion/identifiersInPlainDocstring.py");
406     final LookupElement[] elements = myFixture.completeBasic();
407     assertNotNull(elements);
408     assertContainsElements(Lists.newArrayList(elements),
409                            LookupElementBuilder.create("bar").withAutoCompletionPolicy(AutoCompletionPolicy.NEVER_AUTOCOMPLETE));
410   }
411
412   public void testPep328Completion() {  // PY-3409
413     myFixture.copyDirectoryToProject("completion/pep328", "pep328");
414     myFixture.configureByFile("pep328/package/subpackage1/moduleX.py");
415     myFixture.completeBasic();
416     myFixture.checkResultByFile("completion/pep328/package/subpackage1/moduleX.after.py");
417   }
418
419   public void testImportedSubmoduleCompletion() {  // PY-3227
420     myFixture.copyDirectoryToProject("completion/submodules", "submodules");
421     myFixture.configureByFile("submodules/foo.py");
422     myFixture.completeBasic();
423     myFixture.checkResultByFile("completion/submodules/foo.after.py");
424   }
425
426   public void testFromImportedModuleCompletion() {  // PY-3595
427     myFixture.copyDirectoryToProject("completion/py3595", "");
428     myFixture.configureByFile("moduleX.py");
429     myFixture.completeBasic();
430     myFixture.checkResultByFile("completion/py3595/moduleX.after.py");
431   }
432
433   public void testExportedConstants() {  // PY-3658
434     myFixture.copyDirectoryToProject("completion/exportedConstants", "");
435     myFixture.configureByFile("a.py");
436     myFixture.completeBasic();
437     myFixture.checkResultByFile("completion/exportedConstants/a.after.py");
438   }
439
440   public void testAlias() {  // PY-3672
441     doTest();
442   }
443
444   public void testDuplicateColon() {  // PY-2652
445     doTest();
446   }
447
448   public void testMro() {  // PY-3989
449     doTest();
450   }
451
452   public void testPrivateMemberType() {  // PY-4589
453     doTest();
454   }
455
456   public void testCompleteBeforeSyntaxError() { // PY-3792
457     doTest();
458   }
459
460   // PY-4279
461   public void testFieldReassignment() {
462     doTest();
463   }
464
465   public void testSuperInit() {  // PY-5066
466     doTest();
467   }
468
469   public void testAssignedNearby() {
470     doTest();
471   }
472
473   public void testDunderAll() {
474     doMultiFileTest();
475   }
476
477   public void testAsName() {
478     doMultiFileTest();
479   }
480
481   public void testKeywordArgumentsForImplicitCall() {
482     doTest();
483   }
484
485   public void testTypeMembers() {  // PY-5311
486     assertFalse(doTestByText("a = 'string'\n" +
487                              "a.<caret>").contains("mro"));
488   }
489
490   public void testDunderAllReference() {  // PY-5502
491     doTest();
492   }
493
494   public void testDunderAllReferenceImport() {  // PY-6306
495     doTest();
496   }
497
498   public void testOldStyleClassAttributes() {
499     doTest();
500   }
501
502   // PY-5821
503   public void testGlobalName() {
504     doTest();
505   }
506
507   // PY-6037
508   public void testExceptName() {
509     doTest();
510   }
511
512   public void testQualifiedAssignment() {  // PY-6121
513     doTest();
514   }
515
516   public void testRelativeImportExcludeToplevel() {  // PY-6304
517     setLanguageLevel(LanguageLevel.PYTHON27);
518     try {
519       myFixture.copyDirectoryToProject("completion/relativeImportExcludeToplevel", "");
520       myFixture.configureByFile("pack/subpack/modX.py");
521       myFixture.completeBasic();
522       final List<String> lookupElementStrings = myFixture.getLookupElementStrings();
523       assertNotNull(lookupElementStrings);
524       assertFalse(lookupElementStrings.contains("sys"));
525     }
526     finally {
527       setLanguageLevel(null);
528     }
529   }
530
531   // PY-2813
532   public void testFromNamespacePackageImport() {
533     doMultiFileTest();
534   }
535
536   // PY-6829
537   public void testFakeNameInQualifiedReference() {
538     doTest();
539   }
540
541   // PY-6603
542   public void testNoInitForSubmodules() {
543     doMultiFileTest();
544   }
545
546   public void testUnknownNewReturnType() {  // PY-6671
547     doTest();
548   }
549
550   public void testDunderClass() {  // PY-7327
551     doTest();
552   }
553
554   public void testArgs() {  // PY-7208
555     doTestByText("def foo(*<caret>)");
556     myFixture.checkResult("def foo(*args)");
557   }
558
559   public void testKwArgs() {  // PY-7208
560     doTestByText("def foo(**<caret>)");
561     myFixture.checkResult("def foo(**kwargs)");
562   }
563
564   public void testLocalImportedModule() {  // PY-3668
565     myFixture.copyDirectoryToProject("completion/py3668", "");
566     myFixture.configureByFile("py3668.py");
567     myFixture.completeBasic();
568     myFixture.checkResultByFile("completion/py3668/py3668.after.py");
569   }
570
571   public void testDuplicateDunderAll() {  // PY-6483
572     doTestByText("VAR = 1\nVAR = 2\n__all__ = ['<caret>']");
573     myFixture.checkResult("VAR = 1\n" +
574                           "VAR = 2\n" +
575                           "__all__ = ['VAR']");
576   }
577
578   // PY-7805
579   public void testNoUnderscoredBuiltin() {
580     doTest();
581   }
582
583   public void testParameterFromUsages() {
584     doTest();
585   }
586
587   // PY-1219
588   public void testReCompileMatch() {
589     doTest();
590   }
591
592   public void testReturnTypeOfCallFromUsages() {
593     final List<String> results = doTestByText("def f(x):\n" +
594                                               "    return x\n" +
595                                               "\n" +
596                                               "f('foo').<caret>\n");
597     assertTrue(results.contains("lower"));
598   }
599
600   public void testOverwriteEqualsSign() {  // PY-1337
601     doTestByText("def foo(school=None, kiga=None): pass\n" +
602                  "foo(<caret>school=None)");
603     myFixture.type("sch");
604     myFixture.finishLookup(Lookup.REPLACE_SELECT_CHAR);
605     myFixture.checkResult("def foo(school=None, kiga=None): pass\n" +
606                           "foo(school=None)");
607   }
608
609   public void testOverwriteBracket() {  // PY-6095
610     doTestByText("bar = {'a': '1'}\n" +
611                  "print ba<caret>['a']");
612     myFixture.finishLookup(Lookup.REPLACE_SELECT_CHAR);
613     myFixture.checkResult("bar = {'a': '1'}\n" +
614                           "print bar<caret>['a']");
615   }
616
617   // PY-1860
618   public void testDunderMetaClass() {
619     doTestByText("class C(object):\n" +
620                  "    __meta<caret>\n");
621     myFixture.checkResult("class C(object):\n" +
622                           "    __metaclass__ = \n");
623   }
624
625   // PY-13140
626   public void testModulePrivateNamesCompletedInsideImport() {
627     myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
628     myFixture.configureByFile("a.py");
629     myFixture.completeBasic();
630     List<String> suggested = myFixture.getLookupElementStrings();
631     assertNotNull(suggested);
632     assertContainsElements(suggested, "normal_name", "_private_name", "__magic_name__");
633   }
634
635   // PY-4073
636   public void testFunctionSpecialAttributes() {
637     runWithLanguageLevel(LanguageLevel.PYTHON27, new Runnable() {
638       @Override
639       public void run() {
640         List<String> suggested = doTestByText("def func(): pass; func.func_<caret>");
641         assertNotNull(suggested);
642         assertContainsElements(suggested, PyNames.LEGACY_FUNCTION_SPECIAL_ATTRIBUTES);
643
644         suggested = doTestByText("def func(): pass; func.__<caret>");
645         assertNotNull(suggested);
646         assertContainsElements(suggested, PyNames.FUNCTION_SPECIAL_ATTRIBUTES);
647         assertDoesntContain(suggested, PyNames.PY3_ONLY_FUNCTION_SPECIAL_ATTRIBUTES);
648       }
649     });
650   }
651
652   // PY-9342
653   public void testBoundMethodSpecialAttributes() {
654     List<String>  suggested = doTestByText("{}.update.im_<caret>");
655     assertNotNull(suggested);
656     assertContainsElements(suggested, PyNames.LEGACY_METHOD_SPECIAL_ATTRIBUTES);
657
658     suggested = doTestByText("{}.update.__<caret>");
659     assertNotNull(suggested);
660     assertContainsElements(suggested, PyNames.METHOD_SPECIAL_ATTRIBUTES);
661     assertDoesntContain(suggested, PyNames.FUNCTION_SPECIAL_ATTRIBUTES);
662   }
663
664   // PY-9342
665   public void testWeakQualifierBoundMethodAttributes() {
666     assertUnderscoredMethodSpecialAttributesSuggested();
667   }
668
669   private void assertUnderscoredMethodSpecialAttributesSuggested() {
670     final List<String> suggested = doTestByFile();
671     assertNotNull(suggested);
672     assertContainsElements(suggested, PyNames.METHOD_SPECIAL_ATTRIBUTES);
673     assertDoesntContain(suggested, PyNames.FUNCTION_SPECIAL_ATTRIBUTES);
674   }
675
676   // PY-9342
677   public void testUnboundMethodSpecialAttributes() {
678     runWithLanguageLevel(LanguageLevel.PYTHON27, new Runnable() {
679       @Override
680       public void run() {
681         assertUnderscoredMethodSpecialAttributesSuggested();
682       }
683     });
684     runWithLanguageLevel(LanguageLevel.PYTHON32, new Runnable() {
685       @Override
686       public void run() {
687         assertUnderscoredFunctionAttributesSuggested();
688       }
689     });
690   }
691
692   // PY-9342
693   public void testStaticMethodSpecialAttributes() {
694     assertUnderscoredFunctionAttributesSuggested();
695   }
696
697   // PY-9342
698   public void testLambdaSpecialAttributes() {
699     assertUnderscoredFunctionAttributesSuggested();
700   }
701
702   // PY-9342
703   public void testReassignedMethodSpecialAttributes() {
704     assertUnderscoredMethodSpecialAttributesSuggested();
705   }
706
707   private void assertUnderscoredFunctionAttributesSuggested() {
708     final List<String> suggested = doTestByFile();
709     assertNotNull(suggested);
710     assertContainsElements(suggested, PyNames.FUNCTION_SPECIAL_ATTRIBUTES);
711     assertDoesntContain(suggested, PyNames.METHOD_SPECIAL_ATTRIBUTES);
712   }
713
714   public void testSmartFromUsedMethodsOfString() {
715     final List<String> suggested = doTestSmartByFile();
716     assertNotNull(suggested);
717     // Remove duplicates for assertContainsElements(), "append" comes from bytearray
718     assertContainsElements(new HashSet<String>(suggested), "lower", "capitalize", "join", "append");
719   }
720
721   public void testSmartFromUsedAttributesOfClass() {
722     final List<String> suggested = doTestSmartByFile();
723     assertNotNull(suggested);
724     assertContainsElements(suggested, "other_method", "name", "unique_method");
725   }
726
727   // PY-14388
728   public void testAttributeOfIndirectlyImportedPackage() {
729     doMultiFileTest();
730   }
731
732   // PY-14387
733   public void testSubmoduleOfIndirectlyImportedPackage() {
734     myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
735     myFixture.configureByFile("a.py");
736     myFixture.completeBasic();
737     final List<String> suggested = myFixture.getLookupElementStrings();
738     assertNotNull(suggested);
739     assertSameElements(suggested, "VAR", "subpkg1");
740   }
741
742   // PY-14519
743   public void testOsPath() {
744     myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
745     myFixture.configureByFile("a.py");
746     myFixture.completeBasic();
747     final List<String> suggested = myFixture.getLookupElementStrings();
748     assertNotNull(suggested);
749     assertContainsElements(suggested, "path");
750   }
751
752   // PY-14331
753   public void testExcludedTopLevelPackage() {
754     myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
755     myFixture.configureByFile("a.py");
756     PsiTestUtil.addExcludedRoot(myFixture.getModule(), myFixture.findFileInTempDir("pkg1"));
757     final LookupElement[] variants = myFixture.completeBasic();
758     assertNotNull(variants);
759     assertEmpty(variants);
760   }
761
762   // PY-14331
763   public void testExcludedSubPackage() {
764     myFixture.copyDirectoryToProject("completion/" + getTestName(true), "");
765     myFixture.configureByFile("a.py");
766     PsiTestUtil.addExcludedRoot(myFixture.getModule(), myFixture.findFileInTempDir("pkg1/subpkg1"));
767     final LookupElement[] variants = myFixture.completeBasic();
768     assertNotNull(variants);
769     assertEmpty(variants);
770   }
771
772   public void testStructuralType() {
773     doTest();
774   }
775 }