File tree Expand file tree Collapse file tree 1 file changed +30
-7
lines changed
rewrite-python/src/test/java/org/openrewrite/python Expand file tree Collapse file tree 1 file changed +30
-7
lines changed Original file line number Diff line number Diff line change 1515 */
1616package org .openrewrite .python ;
1717
18+ import org .assertj .core .api .SoftAssertions ;
1819import org .junit .jupiter .api .Test ;
20+ import org .junit .jupiter .api .condition .DisabledIfEnvironmentVariable ;
21+ import org .openrewrite .ParseExceptionResult ;
22+ import org .openrewrite .SourceFile ;
1923import org .openrewrite .python .tree .Py ;
2024import org .openrewrite .test .RewriteTest ;
2125
22- import static org .assertj .core .api .Assertions .assertThat ;
2326import static org .openrewrite .python .Assertions .python ;
2427
28+ @ DisabledIfEnvironmentVariable (named = "CI" , matches = "true" , disabledReason = "No remote client/server available" )
2529class PythonParserTest implements RewriteTest {
2630
2731 @ Test
2832 void parseString () {
2933 rewriteRun (
3034 python (
3135 """
32- import sys
33- print(sys.path)
34- """ ,
35- spec -> spec .afterRecipe (cu -> {
36- assertThat (cu ).isInstanceOf (Py .CompilationUnit .class );
37- })
36+ import sys
37+ print(sys.path)
38+ """ ,
39+ spec -> spec .afterRecipe (cu -> SoftAssertions .assertSoftly (softly -> {
40+ softly .assertThat (cu ).isInstanceOf (Py .CompilationUnit .class );
41+ softly .assertThat (cu .getMarkers ().getMarkers ()).isEmpty ();
42+ })
43+ )
3844 )
3945 );
4046 }
47+
48+ @ Test
49+ void parseStringWithParser () {
50+ SourceFile sf = PythonParser .builder ().build ()
51+ .parse (
52+ //language=python
53+ """
54+ import sys
55+ print(sys.path)
56+ """ )
57+ .findFirst ()
58+ .get ();
59+ SoftAssertions .assertSoftly (softly -> {
60+ softly .assertThat (sf ).isInstanceOf (Py .CompilationUnit .class );
61+ softly .assertThat (sf .getMarkers ().getMarkers ()).isEmpty ();
62+ });
63+ }
4164}
You can’t perform that action at this time.
0 commit comments