From a1a541a0daf568f9af15387c19a2e260d8bcb91b Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 31 May 2018 19:21:30 +0300 Subject: [PATCH] PyTest fixtures and parametrized completions tests --- .../testCompletion/after_test_test.txt | 19 +++++++++++ .../test_for_inspection_test.py | 11 ++++++ python/testData/testCompletion/test_test.py | 19 +++++++++++ .../PyTestFixtureAndParametrizedTest.kt | 34 +++++++++++++++++++ 4 files changed, 83 insertions(+) create mode 100644 python/testData/testCompletion/after_test_test.txt create mode 100644 python/testData/testCompletion/test_for_inspection_test.py create mode 100644 python/testData/testCompletion/test_test.py create mode 100644 python/testSrc/com/jetbrains/python/testing/PyTestFixtureAndParametrizedTest.kt diff --git a/python/testData/testCompletion/after_test_test.txt b/python/testData/testCompletion/after_test_test.txt new file mode 100644 index 000000000000..b149cdb03fa9 --- /dev/null +++ b/python/testData/testCompletion/after_test_test.txt @@ -0,0 +1,19 @@ +import pytest + +# +@pytest.fixture +def my_fixture(): + pass + +@pytest.fixture +def ham(my_fixture): + pass + + +def test_sample_test(my_fixture): + pass + +@pytest.mark.parametrize(('spam,eggs'), [(1,1), (2,3), (3,3)]) +@pytest.mark.parametrize('first,second', [(1,1), (2,3), (3,3)]) +def test_sample(spam,eggs,first,second): + pass \ No newline at end of file diff --git a/python/testData/testCompletion/test_for_inspection_test.py b/python/testData/testCompletion/test_for_inspection_test.py new file mode 100644 index 000000000000..df5fa67c9c71 --- /dev/null +++ b/python/testData/testCompletion/test_for_inspection_test.py @@ -0,0 +1,11 @@ +import pytest + +# +@pytest.fixture +def foo(): + pass + +@pytest.mark.parametrize(('spam,eggs'), [(1,1), (2,3), (3,3)]) +@pytest.mark.parametrize('first,second', [(1,1), (2,3), (3,3)]) +def test_sample(apple, foo, spam): + pass \ No newline at end of file diff --git a/python/testData/testCompletion/test_test.py b/python/testData/testCompletion/test_test.py new file mode 100644 index 000000000000..159abd878573 --- /dev/null +++ b/python/testData/testCompletion/test_test.py @@ -0,0 +1,19 @@ +import pytest + +# +@pytest.fixture +def my_fixture(): + pass + +@pytest.fixture +def ham(my_fixt): + pass + + +def test_sample_test(my_fixt): + pass + +@pytest.mark.parametrize(('spam,eggs'), [(1,1), (2,3), (3,3)]) +@pytest.mark.parametrize('first,second', [(1,1), (2,3), (3,3)]) +def test_sample(spa,egg,firs,secon): + pass \ No newline at end of file diff --git a/python/testSrc/com/jetbrains/python/testing/PyTestFixtureAndParametrizedTest.kt b/python/testSrc/com/jetbrains/python/testing/PyTestFixtureAndParametrizedTest.kt new file mode 100644 index 000000000000..c76e7d96802b --- /dev/null +++ b/python/testSrc/com/jetbrains/python/testing/PyTestFixtureAndParametrizedTest.kt @@ -0,0 +1,34 @@ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. +package com.jetbrains.python.testing + +import com.jetbrains.python.PyNames +import com.jetbrains.python.fixtures.PyTestCase +import com.jetbrains.python.inspections.PyUnusedLocalInspection +import com.jetbrains.python.testing.pyTestParametrized.PyTestParametrizedInspection + +/** + * Test py.test fixtures and paramterized completions and inspections + */ +class PyTestFixtureAndParametrizedTest : PyTestCase() { + override fun getTestDataPath() = super.getTestDataPath() + "/testCompletion" + override fun setUp() { + super.setUp() + TestRunnerService.getInstance(myFixture.module).projectConfiguration = + PyTestFrameworkService.getSdkReadableNameByFramework(PyNames.PY_TEST) + } + + fun testInspection() { + myFixture.copyDirectoryToProject(".", ".") + myFixture.configureByFile("test_for_inspection_test.py") + myFixture.enableInspections(PyUnusedLocalInspection::class.java, PyTestParametrizedInspection::class.java) + myFixture.checkHighlighting(true, false, true) + } + + fun testCompletion() { + + myFixture.copyDirectoryToProject(".", ".") + myFixture.configureByFile("test_test.py") + myFixture.completeBasicAllCarets(null) + myFixture.checkResultByFile("after_test_test.txt") + } +} \ No newline at end of file