1 /* 2 SPDX-FileCopyrightText: 2010 Miquel Canes Gonzalez <miquelcanes@gmail.com> 3 SPDX-FileCopyrightText: 2011-2012 Sven Brauch <svenbrauch@googlemail.com> 4 5 SPDX-License-Identifier: MIT 6 */ 7 8 #ifndef PYDUCHAINTEST_H 9 #define PYDUCHAINTEST_H 10 11 #include <QObject> 12 #include <QTemporaryDir> 13 #include "ast.h" 14 #include <serialization/indexedstring.h> 15 #include <language/duchain/topducontext.h> 16 #include <tests/testfile.h> 17 18 namespace KDevelop { 19 class TopDUContext; 20 class ReferencedTopDUContext; 21 } 22 23 using namespace KDevelop; 24 25 class PyDUChainTest : public QObject 26 { 27 Q_OBJECT 28 public: 29 explicit PyDUChainTest(QObject* parent = nullptr); 30 void initShell(); 31 ~PyDUChainTest() override; 32 33 KDevelop::ReferencedTopDUContext parse(const QString& code); 34 35 Python::CodeAst::Ptr m_ast; 36 37 private slots: 38 void init(); 39 void testSimple(); 40 void testSimple_data(); 41 void testRanges(); 42 void testRanges_data(); 43 void testTypes(); 44 void testTypes_data(); 45 void testImportDeclarations(); 46 void testImportDeclarations_data(); 47 void testImportFiles(); 48 void testCrashes(); 49 void testCrashes_data(); 50 void testFlickering(); 51 void testFlickering_data(); 52 void testFunctionArgs(); 53 void testAutocompletionFlickering(); 54 void testContainerTypes(); 55 void testContainerTypes_data(); 56 void testInheritance(); 57 void testInheritance_data(); 58 void testClassVariables(); 59 void testWarnNewNotCls(); 60 void testWarnNewNotCls_data(); 61 void testBinaryOperatorsUnsure(); 62 void testBinaryOperatorsUnsure_data(); 63 void testClassContextRanges(); 64 void testVarKWArgs(); 65 void testMultiFromImport(); 66 void testMultiFromImport_data(); 67 void testRelativeImport(); 68 void testRelativeImport_data(); 69 void testCannotOverwriteBuiltins(); 70 void testFunctionHints(); 71 void testFunctionHints_data(); 72 void testCannotOverwriteBuiltins_data(); 73 void testOperators(); 74 void testOperators_data(); 75 void testVariableCreation(); 76 void testVariableCreation_data(); 77 void testProblemCount(); 78 void testProblemCount_data(); 79 void testHintedTypes(); 80 void testHintedTypes_data(); 81 void testCleanupMultiplePasses(); 82 void testComments(); 83 void testComments_data(); 84 void testManyDeclarations(); 85 86 87 private: 88 QList<KDevelop::TestFile*> createdFiles; 89 QTemporaryDir testDirOwner; 90 QDir testDir; 91 QDir assetsDir; 92 QString lastTest; 93 94 QList<QString> FindPyFiles(QDir& root); 95 }; 96 97 #endif // PYDUCHAINTEST_H 98