PyTest fixtures and parametrized completions tests

This commit is contained in:
Ilya.Kazakevich
2018-05-31 19:26:37 +03:00
parent 17ff674fa8
commit a1a541a0da
4 changed files with 83 additions and 0 deletions
@@ -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
@@ -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(<weak_warning descr="Parameter 'apple' value is not used">apple</weak_warning>, foo, spam<warning descr="Following arguments are not declared but provided by decorator: [eggs, first, second]">)</warning>:
pass
@@ -0,0 +1,19 @@
import pytest
#
@pytest.fixture
def my_fixture():
pass
@pytest.fixture
def ham(my_fixt<caret>):
pass
def test_sample_test(my_fixt<caret>):
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<caret>,egg<caret>,firs<caret>,secon<caret>):
pass
@@ -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")
}
}