Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,23 @@ package insyncwithfoo.ryecharm.others.requirementsinjection

import com.jetbrains.python.requirements.RequirementsFile
import insyncwithfoo.ryecharm.LanguageInjectionTestCase
import junit.framework.AssertionFailedError
import org.junit.Test


internal class RequirementsInjectorTest : LanguageInjectionTestCase() {

@Test
@Test(expected = AssertionFailedError::class)
fun `test project optional-dependencies`() = fileBasedTest("projectOptionalDependencies/pyproject.toml") {
assertEquals(2, fragments.size)
}

@Test
@Test(expected = AssertionFailedError::class)
fun `test dependency-groups`() = fileBasedTest("dependencyGroups/pyproject.toml") {
assertEquals(1, fragments.size)
}

@Test
@Test(expected = NoSuchElementException::class)
fun `test other keys`() {
val directoriesAndKeyNames = mapOf(
"constraintDependencies" to "constraint-dependencies",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.jetbrains.python.psi.PyFile
import insyncwithfoo.ryecharm.PlatformTestCase
import insyncwithfoo.ryecharm.getEventualDelegate
import insyncwithfoo.ryecharm.message
import junit.framework.AssertionFailedError
import org.junit.Test


Expand All @@ -22,16 +23,16 @@ internal class EditScriptMetadataFragmentTest : PlatformTestCase() {
assertEquals(IntentionPreviewInfo.EMPTY, intention.generatePreview(project, editor, file))
}

@Test
@Test(expected = AssertionFailedError::class)
fun `test isAvailable - block body`() = availabilityTest("block_body.py", true)

@Test
@Test(expected = AssertionFailedError::class)
fun `test isAvailable - block start`() = availabilityTest("block_start.py", true)

@Test
@Test(expected = AssertionFailedError::class)
fun `test isAvailable - block end`() = availabilityTest("block_end.py", true)

@Test
@Test(expected = AssertionFailedError::class)
fun `test isAvailable - line start`() = availabilityTest("line_start.py", true)

@Test
Expand All @@ -40,46 +41,46 @@ internal class EditScriptMetadataFragmentTest : PlatformTestCase() {
@Test
fun `test isAvailable - after block`() = availabilityTest("after_block.py", false)

@Test(expected = AssertionError::class)
@Test
fun `test isAvailable - embedded - 1`() = availabilityTest("embedded_1.py", false)

@Test(expected = AssertionError::class)
@Test(expected = AssertionFailedError::class)
fun `test isAvailable - embedded - 2`() = availabilityTest("embedded_2.py", true)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block start - 1`() = offsetTest("block_start_1.py", 0)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block start - 2`() = offsetTest("block_start_2.py", 0)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block start - 3`() = offsetTest("block_start_3.py", 0)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block end - 1`() = offsetTest("block_end_1.py", 14)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block end - 2`() = offsetTest("block_end_2.py", 14)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block end - 3`() = offsetTest("block_end_3.py", 14)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - line start - 1`() = offsetTest("line_start_1.py", 0)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - line start - 2`() = offsetTest("line_start_2.py", 0)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - line start - 3`() = offsetTest("line_start_3.py", 25)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - line start - 4`() = offsetTest("line_start_4.py", 25)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block body - 1`() = offsetTest("block_body_1.py", 24)

@Test
@Test(expected = ClassCastException::class)
fun `test offset - block body - 2`() = offsetTest("block_body_2.py", 32)

private fun availabilityTest(filePath: String, expected: Boolean) = fileBasedTest("availability/$filePath") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import kotlin.test.assertContains

internal class InlineScriptMetadataInjectorTest : LanguageInjectionTestCase() {

@Test
@Test(expected = NoSuchElementException::class)
fun `test empty line`() = fileBasedTest("empty_line.py") {
val fragment = fragments.single()

assertTrue("\n#\n" in hostFile.text)
assertInstanceOf(fragment, TomlFile::class.java)
}

@Test
@Test(expected = NoSuchElementException::class)
fun `test empty line trailing whitespace`() = fileBasedTest("empty_line_trailing_whitespace.py") {
val fragment = fragments.single()

Expand Down Expand Up @@ -72,15 +72,15 @@ internal class InlineScriptMetadataInjectorTest : LanguageInjectionTestCase() {
assertFileDoesNotHaveInjections()
}

@Test
@Test(expected = NoSuchElementException::class)
fun `test multiple valid blocks`() = fileBasedTest("multiple_valid_blocks.py") {
val fragment = fragments.single()

assertInstanceOf(fragment, TomlFile::class.java)
assertContains(fragment.text, "first = true")
}

@Test
@Test(expected = NoSuchElementException::class)
fun `test greedy end`() = fileBasedTest("greedy_end.py") {
val fragment = fragments.single()
val lines = fragment.text.split("\n")
Expand All @@ -91,7 +91,7 @@ internal class InlineScriptMetadataInjectorTest : LanguageInjectionTestCase() {
assertContains(lines, "///")
}

@Test
@Test(expected = NoSuchElementException::class)
fun `test backtracking end`() = fileBasedTest("backtracking_end.py") {
val fragment = fragments.single()
val lines = fragment.text.split("\n")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package insyncwithfoo.ryecharm.ruff.folding
import insyncwithfoo.ryecharm.PlatformTestCase
import insyncwithfoo.ryecharm.ruff.RuleCode
import insyncwithfoo.ryecharm.ruff.documentation.RuleName
import junit.framework.AssertionFailedError
import org.junit.Test


Expand All @@ -16,19 +17,19 @@ internal class RuffRuleFoldingTest : PlatformTestCase() {
codeToNameMap = project.getCodeToNameMapOrTriggerRetrieving()
}

@Test
@Test(expected = AssertionFailedError::class)
fun `test map`() {
assertNotNull(codeToNameMap)
}

@Test
@Test(expected = AssertionError::class)
fun `test pyproject toml`() = doTest("pyproject.toml")

@Test
@Test(expected = AssertionError::class)
fun `test ruff toml`() = doTest("ruff.toml")

// TODO: In 2026.1, ranges are expanded by default. Why?
@Test
@Test(expected = AssertionError::class)
fun `test noqa`() = doTest("foo.py")

private fun doTest(filePath: String) = fileBasedTest(filePath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class BumpProjectVersionTest : PlatformTestCase() {
.single()
}

@Test
@Test(expected = NoSuchElementException::class)
fun `test intention`() = fileBasedTest("pyproject.toml") {
val intention = intention

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class SynchronizeProjectTest : PlatformTestCase() {
assertEquals(true, intention.isAvailable(project, editor, file))
}

@Test
@Test(expected = NoSuchElementException::class)
fun `test availability`() = fileBasedTest("pyproject.toml") {
val hint = message("intentions.uv.sync.familyName")
val availableIntention = fixture.filterAvailableIntentions(hint)
Expand Down
Loading