// ĠCopyright Ġ 2 0 0 0 - 2 0 2 1 ĠJetBrains Ġs . r . o . Ġand Ġcontributors . Ġ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 . sdk Ċ Ċ import Ġcom . intellij . openapi . Disposable Ċ import Ġcom . intellij . openapi . application . Application Manager Ċ import Ġcom . intellij . openapi . application . run Write Action And Wait Ċ import Ġcom . intellij . openapi . module . Module Ċ import Ġcom . intellij . openapi . project Roots . Project J dk Table Ċ import Ġcom . intellij . openapi . project Roots . Sdk Ċ import Ġcom . intellij . openapi . project Roots . impl . Project J dk Impl Ċ import Ġcom . intellij . openapi . roots . Order Root Type Ċ import Ġcom . intellij . openapi . util . Dis poser Ċ import Ġcom . intellij . openapi . util . io . File Util Ċ import Ġcom . intellij . openapi . vfs . Local FileSystem Ċ import Ġcom . intellij . openapi . vfs . V fs Util Ċ import Ġcom . intellij . openapi . vfs . Virtual File Ċ import Ġcom . intellij . test Framework . Application Rule Ċ import Ġcom . intellij . test Framework . Platform TestUtil Ċ import Ġcom . intellij . test Framework . V fs TestUtil Ċ import Ġcom . intellij . test Framework . assertions . Assertions . assertThat Ċ import Ġcom . intellij . test Framework . replace Service Ċ import Ġcom . intellij . test Framework . rules . Project Model Rule Ċ import Ġcom . jetbrains . python . Py Names Ċ import Ġcom . jetbrains . python . Python Mock Sdk Ċ import Ġcom . jetbrains . python . Python Plugin Disposable Ċ import Ġcom . jetbrains . python . configuration . Py Configurable Interpreter List Ċ import Ġcom . jetbrains . python . psi . Language Level Ċ import Ġcom . jetbrains . python . psi . Py Util Ċ import Ġorg . jetbrains . annotations . NotNull Ċ import Ġorg . junit . Class Rule Ċ import Ġorg . junit . Rule Ċ import Ġorg . junit . Test Ċ Ċ class ĠPy Sdk Paths Test Ġ{ ĊĊĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠ Ġ@ Jvm Field ĊĠĠĠ Ġ@ Class Rule ĊĠĠĠ Ġval Ġapp Rule Ġ= ĠApplication Rule () ĊĠ Ġ} ĊĊĠ Ġ@ Rule ĊĠ Ġ@ Jvm Field ĊĠ Ġval Ġproject Model Ġ= ĠProject Model Rule () ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsys Path Entry Is Excluded Path () Ġ{ ĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create () ĊĊĠĠĠ Ġval Ġexcluded Ġ= Ġcreate In Sdk Root ( sdk , Ġ" my _ excluded ") ĊĠĠĠ Ġval Ġincluded Ġ= Ġcreate In Sdk Root ( sdk , Ġ" my _ included ") ĊĊĠĠĠ Ġsdk . put UserData ( Python Sdk Type . MOCK _ SYS _ PATH _ KEY , ĠlistOf ( sdk . home Path , Ġexcluded . path , Ġincluded . path )) ĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk . get OrCreate Additional Data () Ġ}. apply Ġ{ Ġset Excluded Paths From Virtual Files ( set Of ( excluded )) Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġval Ġroot Provider Ġ= Ġsdk . root Provider ĊĠĠĠ Ġval Ġsdk Roots Ġ= Ġroot Provider . get Files ( Order Root Type . CLASSES ) ĊĠĠĠ ĠassertThat ( sdk Roots ). contains ( included ) ĊĠĠĠ ĠassertThat ( sdk Roots ). does Not Contain ( excluded ) ĊĠĠĠ ĠassertThat ( root Provider . get Files ( Order Root Type . SOURCES )). isEmpty () ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġuser Added Is Module Root () Ġ{ ĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create (). also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk . get OrCreate Additional Data () Ġ}. apply Ġ{ Ġset Added Paths From Virtual Files ( set Of ( module Root )) Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root ), Ġempty List ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsys Path Entry Is Module Root () Ġ{ ĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create (). also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġsdk . put UserData ( Python Sdk Type . MOCK _ SYS _ PATH _ KEY , ĠlistOf ( sdk . home Path , Ġmodule Root . path )) ĊĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root ), Ġempty List ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġuser Added In Module And Sdk In Module But User Added NotIn Sdk () Ġ{ ĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Path Ġ= Ġcreate V env Structure In Module ( module Root ). path ĊĊĠĠĠ Ġval Ġuser Added Path Ġ= Ġcreate Sub dir ( module Root ) ĊĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create ( sdk Path ). also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk . get OrCreate Additional Data () Ġ}. apply Ġ{ Ġset Added Paths From Virtual Files ( set Of ( user Added Path )) Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root , Ġuser Added Path ), Ġempty List ()) ĊĊĠĠĠ Ġval Ġsimple Sdk Ġ= ĠPython Mock Sdk . create (). also Ġ{ ĊĠĠĠĠĠ Ġremove Transfer red Roots ( module , Ġsdk ) ĊĠĠĠĠĠ Ġmodule . python Sdk Ġ= Ġit ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( simple Sdk ) ĊĊĠĠĠ Ġcheck Roots ( simple Sdk , Ġmodule , ĠlistOf ( module Root ), Ġempty List ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġuser Added Via Editable Sdk With Shared Data () Ġ{ ĊĠĠĠ Ġ// Ġem ulates Ġcom . jetbrains . python . configuration . Python Sdk Details Dialog . Show Path Button . action Performed ĊĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Path Ġ= Ġcreate V env Structure In Module ( module Root ). path ĊĊĠĠĠ Ġval Ġuser Added Path Ġ= Ġcreate Sub dir ( module Root ) ĊĊĠĠĠ Ġval Ġpython Version Ġ= ĠLanguage Level . getDefault (). to Python Version () ĊĠĠĠ Ġval Ġsdk Ġ= ĠProject J dk Impl ( ĊĠĠĠĠĠ Ġ" Mock Ġ${ Py Names . PYTHON _ SDK _ ID _ NAME } Ġ$ python Version ", ĊĠĠĠĠĠ ĠPython Sdk Type . getInstance (), ĊĠĠĠĠĠ Ġ"$ sdk Path / bin / python ", ĊĠĠĠĠĠ Ġpython Version ĊĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ. also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġsdk . put UserData ( Python Sdk Type . MOCK _ PY _ VERSION _ KEY , Ġpython Version ) ĊĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk . get OrCreate Additional Data () Ġ} ĊĠĠĠ Ġrun Write Action And Wait Ġ{ ĠProject J dk Table . getInstance (). add J dk ( sdk ) Ġ} ĊĊĠĠĠ Ġval Ġeditable Sdk Ġ= ĠPy Configurable Interpreter List . getInstance ( project Model . project ). model . find Sdk ( sdk . name ) ĊĠĠĠ Ġeditable Sdk !!. put UserData ( Python Sdk Type . MOCK _ PY _ VERSION _ KEY , Ġpython Version ) ĊĠĠĠ ĠDis poser . register ( project Model . project , Ġeditable Sdk Ġas ĠDis posable ) ĊĊĠĠĠ Ġ// Ġ--- ĠADD Ġpath Ġ--- ĊĠĠĠ Ġval Ġsdk Mod ific ator Ġ= Ġeditable Sdk . sdk Mod ific ator ĊĠĠĠ Ġ( sdk Mod ific ator . sdk Additional Data Ġas ĠPython Sdk Additional Data ). set Added Paths From Virtual Files ( set Of ( user Added Path )) ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk Mod ific ator . commit Changes () Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( editable Sdk ) ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) Ġ// Ġsince Ġeditable Sdk Ġwas Ġcreated Ġafter Ġadditional Ġdata Ġhad Ġbeen Ġcreated Ġfor Ġsdk , Ġthey Ġshare Ġthe Ġsame Ġdata ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root , Ġuser Added Path ), Ġempty List ()) ĊĊĠĠĠ Ġ// Ġ--- ĠREMOVE Ġpath Ġ--- ĊĠĠĠ Ġval Ġsdk Mod ific ator 2 Ġ= Ġeditable Sdk . sdk Mod ific ator ĊĠĠĠ Ġ( sdk Mod ific ator 2 . sdk Additional Data Ġas ĠPython Sdk Additional Data ). set Added Paths From Virtual Files ( empty Set ()) ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk Mod ific ator 2 . commit Changes () Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( editable Sdk ) ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) Ġ// Ġsince Ġeditable Sdk Ġwas Ġcreated Ġafter Ġadditional Ġdata Ġhad Ġbeen Ġcreated Ġfor Ġsdk , Ġthey Ġshare Ġthe Ġsame Ġdata ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root ), Ġempty List ()) ĊĊĠĠĠ Ġrun Write Action And Wait Ġ{ ĠProject J dk Table . getInstance (). remove J dk ( sdk ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġuser Added Via Editable Sdk Without Shared Data () Ġ{ ĊĠĠĠ Ġ// Ġem ulates Ġcom . jetbrains . python . configuration . Python Sdk Details Dialog . Show Path Button . action Performed ĊĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Path Ġ= Ġcreate V env Structure In Module ( module Root ). path ĊĊĠĠĠ Ġval Ġuser Added Path Ġ= Ġcreate Sub dir ( module Root ) ĊĊĠĠĠ Ġval Ġpython Version Ġ= ĠLanguage Level . getDefault (). to Python Version () ĊĠĠĠ Ġval Ġsdk Ġ= ĠProject J dk Impl ( ĊĠĠĠĠĠ Ġ" Mock Ġ${ Py Names . PYTHON _ SDK _ ID _ NAME } Ġ$ python Version ", ĊĠĠĠĠĠ ĠPython Sdk Type . getInstance (), ĊĠĠĠĠĠ Ġ"$ sdk Path / bin / python ", ĊĠĠĠĠĠ Ġpython Version ĊĠĠĠ Ġ) ĊĠĠĠĠĠ Ġ. also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġsdk . put UserData ( Python Sdk Type . MOCK _ PY _ VERSION _ KEY , Ġpython Version ) ĊĠĠĠ Ġrun Write Action And Wait Ġ{ ĠProject J dk Table . getInstance (). add J dk ( sdk ) Ġ} ĊĊĠĠĠ Ġval Ġeditable Sdk Ġ= ĠPy Configurable Interpreter List . getInstance ( project Model . project ). model . find Sdk ( sdk . name ) ĊĠĠĠ Ġeditable Sdk !!. put UserData ( Python Sdk Type . MOCK _ PY _ VERSION _ KEY , Ġpython Version ) ĊĠĠĠ ĠDis poser . register ( project Model . project , Ġeditable Sdk Ġas ĠDis posable ) ĊĊĠĠĠ Ġ// Ġ--- ĠADD Ġpath Ġ--- ĊĠĠĠ Ġval Ġsdk Mod ific ator Ġ= Ġeditable Sdk . sdk Mod ific ator ĊĠĠĠ ĠassertThat ( sdk Mod ific ator . sdk Additional Data ). isNull () ĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġsdk Mod ific ator . sdk Additional Data Ġ= ĠPython Sdk Additional Data ( null ). apply Ġ{ ĊĠĠĠĠĠ Ġset Added Paths From Virtual Files ( set Of ( user Added Path )) ĊĠĠĠ Ġ} ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk Mod ific ator . commit Changes () Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( editable Sdk ) ĊĊĠĠĠ Ġrun Write Action And Wait Ġ{ ĠProject J dk Table . getInstance (). update J dk ( sdk , Ġeditable Sdk ) Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root , Ġuser Added Path ), Ġempty List ()) ĊĊĠĠĠ Ġ// Ġ--- ĠREMOVE Ġpath Ġ--- ĊĠĠĠ Ġval Ġsdk Mod ific ator 2 Ġ= Ġeditable Sdk . sdk Mod ific ator ĊĠĠĠ Ġ( sdk Mod ific ator 2 . sdk Additional Data Ġas ĠPython Sdk Additional Data ). set Added Paths From Virtual Files ( empty Set ()) ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk Mod ific ator 2 . commit Changes () Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( editable Sdk ) ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) Ġ// Ġafter Ġupdate J dk Ġcall Ġeditable Sdk Ġand Ġsdk Ġshare Ġthe Ġsame Ġdata ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root ), Ġempty List ()) ĊĊĠĠĠ Ġrun Write Action And Wait Ġ{ ĠProject J dk Table . getInstance (). remove J dk ( sdk ) Ġ} ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsys Path Entry In Module And Sdk In Module But Entry NotIn Sdk () Ġ{ ĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Path Ġ= Ġcreate V env Structure In Module ( module Root ). path ĊĊĠĠĠ Ġval Ġentry Path Ġ= Ġcreate Sub dir ( module Root ) ĊĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create ( sdk Path ). also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġsdk . put UserData ( Python Sdk Type . MOCK _ SYS _ PATH _ KEY , ĠlistOf ( sdk . home Path , Ġentry Path . path )) ĊĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root , Ġentry Path ), Ġempty List ()) ĊĊĠĠĠ Ġval Ġsimple Sdk Ġ= ĠPython Mock Sdk . create (). also Ġ{ ĊĠĠĠĠĠ Ġremove Transfer red Roots ( module , Ġsdk ) ĊĠĠĠĠĠ Ġmodule . python Sdk Ġ= Ġit ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( simple Sdk ) ĊĊĠĠĠ Ġcheck Roots ( simple Sdk , Ġmodule , ĠlistOf ( module Root ), Ġempty List ()) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġuser Added In Sdk And Sdk In Module () Ġ{ ĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Dir Ġ= Ġcreate V env Structure In Module ( module Root ) ĊĊĠĠĠ Ġval Ġuser Added Path Ġ= Ġcreate Sub dir ( sdk Dir ) ĊĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create ( sdk Dir . path ). also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġrun Write Action And Wait Ġ{ Ġsdk . get OrCreate Additional Data () Ġ}. apply Ġ{ Ġset Added Paths From Virtual Files ( set Of ( user Added Path )) Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root ), ĠlistOf ( user Added Path )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsys Path Entry In Sdk And Sdk In Module () Ġ{ ĊĠĠĠ Ġval Ġ( module , Ġmodule Root ) Ġ= Ġcreate Module () ĊĊĠĠĠ Ġval Ġsdk Dir Ġ= Ġcreate V env Structure In Module ( module Root ) ĊĊĠĠĠ Ġval Ġentry Path Ġ= Ġcreate Sub dir ( sdk Dir ) ĊĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create ( sdk Dir . path ). also Ġ{ Ġmodule . python Sdk Ġ= Ġit Ġ} ĊĠĠĠ Ġsdk . put UserData ( Python Sdk Type . MOCK _ SYS _ PATH _ KEY , ĠlistOf ( sdk . home Path , Ġentry Path . path )) ĊĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule , ĠlistOf ( module Root ), ĠlistOf ( entry Path )) ĊĠ Ġ} ĊĊĠ Ġ@ Test ĊĠ Ġfun Ġsys Path Entry Outside Sdk And Module 1 But Inside Module 2 () Ġ{ ĊĠĠĠ Ġval Ġ( module 1 , Ġmodule Root 1 ) Ġ= Ġcreate Module (" m 1 ") ĊĠĠĠ Ġval Ġ( module 2 , Ġmodule Root 2 ) Ġ= Ġcreate Module (" m 2 ") ĊĊĠĠĠ Ġval Ġsdk Dir Ġ= Ġcreate V env Structure In Module ( module Root 1 ) ĊĊĠĠĠ Ġval Ġentry Path 1 Ġ= Ġcreate Sub dir ( module Root 1 ) ĊĠĠĠ Ġval Ġentry Path 2 Ġ= Ġcreate Sub dir ( module Root 2 ) ĊĊĠĠĠ Ġval Ġsdk Ġ= ĠPython Mock Sdk . create ( sdk Dir . path ). also Ġ{ ĊĠĠĠĠĠ Ġmodule 1 . python Sdk Ġ= Ġit ĊĠĠĠĠĠ Ġmodule 2 . python Sdk Ġ= Ġit ĊĠĠĠ Ġ} ĊĠĠĠ Ġsdk . put UserData ( Python Sdk Type . MOCK _ SYS _ PATH _ KEY , ĠlistOf ( sdk . home Path , Ġentry Path 1 . path , Ġentry Path 2 . path )) ĊĊĠĠĠ Ġmock Python Plugin Disposable () ĊĠĠĠ Ġupdate Sdk Paths ( sdk ) ĊĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule 1 , ĠlistOf ( module Root 1 , Ġentry Path 1 , Ġentry Path 2 ), Ġempty List ()) ĊĠĠĠ Ġcheck Roots ( sdk , Ġmodule 2 , ĠlistOf ( module Root 2 , Ġentry Path 1 , Ġentry Path 2 ), Ġempty List ()) ĊĊĠĠĠ Ġval Ġsimple Sdk Ġ= ĠPython Mock Sdk . create (). also Ġ{ ĊĠĠĠĠĠ Ġremove Transfer red Roots ( module 1 , Ġsdk ) ĊĠĠĠĠĠ Ġmodule 1 . python Sdk Ġ= Ġit ĊĊĠĠĠĠĠ Ġremove Transfer red Roots ( module 2 , Ġsdk ) ĊĠĠĠĠĠ Ġmodule 2 . python Sdk Ġ= Ġit ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġupdate Sdk Paths ( simple Sdk ) ĊĊĠĠĠ Ġcheck Roots ( simple Sdk , Ġmodule 1 , ĠlistOf ( module Root 1 ), Ġempty List ()) ĊĠĠĠ Ġcheck Roots ( simple Sdk , Ġmodule 2 , ĠlistOf ( module Root 2 ), Ġempty List ()) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Module ( name : ĠString Ġ= Ġ" module "): ĠPair < Module , ĠVirtual File > Ġ{ ĊĠĠĠ Ġval Ġmodule Root Ġ= ĠLocal FileSystem . getInstance (). refresh And Find File By Io File ( ĊĠĠĠĠĠ ĠFile Util . create Temp Directory (" my ", Ġ" project ", Ġfalse ) ĊĠĠĠ Ġ) !!. also Ġ{ Ġdelete On Tear Down ( it ) Ġ} ĊĊĠĠĠ Ġval Ġmodule Ġ= Ġproject Model . create Module ( name ) ĊĠĠĠ ĠassertThat ( Py Util . getSource Roots ( module )). isEmpty () ĊĊĠĠĠ Ġmodule . root Manager . modifiable Model . apply Ġ{ ĊĠĠĠĠĠ Ġadd Content Entry ( module Root ) ĊĠĠĠĠĠ Ġrun Write Action And Wait Ġ{ Ġcommit () Ġ} ĊĠĠĠ Ġ} ĊĠĠĠ ĠassertThat ( Py Util . getSource Roots ( module )). contains Only ( module Root ) ĊĊĠĠĠ Ġreturn Ġmodule Ġto Ġmodule Root ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate V env Structure In Module ( module Root : ĠVirtual File ): ĠVirtual File Ġ{ ĊĠĠĠ Ġreturn Ġrun Write Action And Wait Ġ{ ĊĠĠĠĠĠ Ġval Ġvenv Ġ= Ġmodule Root . create Child Directory ( this , Ġ" venv ") ĊĊĠĠĠĠĠ Ġvenv . create Child Data ( this , Ġ" py venv . cfg ") Ġ Ġ// Ġsee ĠPython Sdk Util . get Virtual Env Root ĊĊĠĠĠĠĠ Ġval Ġbin Ġ= Ġvenv . create Child Directory ( this , Ġ" bin ") ĊĠĠĠĠĠ Ġbin . create Child Data ( this , Ġ" python ") ĊĊĠĠĠĠĠ Ġvenv ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate Sub dir ( dir : ĠVirtual File ): ĠVirtual File Ġ{ ĊĠĠĠ Ġreturn Ġrun Write Action And Wait Ġ{ Ġdir . create Child Directory ( this , Ġ" my lib ") Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġmock Python Plugin Disposable () Ġ{ ĊĠĠĠ ĠApplication Manager . getApplication (). replace Service ( Python Plugin Disposable :: class . java , ĠPython Plugin Disposable (), Ġproject Model . project ) ĊĠĠĠ ĠDis poser . register ( project Model . project , ĠPython Plugin Disposable . getInstance ()) ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġupdate Sdk Paths ( sdk : Ġ@ NotNull ĠS dk ) Ġ{ ĊĠĠĠ ĠPython Sdk Updater . update Version And Paths S ynchronously And Schedule Remaining ( sdk , Ġproject Model . project ) ĊĠĠĠ ĠApplication Manager . getApplication (). invoke And Wait Ġ{ ĠPlatform TestUtil . dispatch All Invocation Events In Ide EventQueue () Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcheck Roots ( sdk : ĠS dk , Ġmodule : ĠModule , Ġmodule Roots : ĠList < Virtual File >, Ġsdk Roots : ĠList < Virtual File >) Ġ{ ĊĠĠĠ ĠassertThat ( Py Util . getSource Roots ( module )). contains Exactly In Any Order (* module Roots . to Typed Array ()) ĊĊĠĠĠ Ġval Ġroot Provider Ġ= Ġsdk . root Provider ĊĠĠĠ Ġval Ġclasses Ġ= Ġroot Provider . get Files ( Order Root Type . CLASSES ) ĊĠĠĠ ĠassertThat ( classes ). contains All ( sdk Roots ) ĊĠĠĠ ĠassertThat ( classes ). does Not Contain (* module Roots . to Typed Array ()) ĊĠĠĠ ĠassertThat ( root Provider . get Files ( Order Root Type . SOURCES )). isEmpty () ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġcreate In Sdk Root ( sdk : ĠS dk , Ġrelative Path : ĠString ): ĠVirtual File Ġ{ ĊĠĠĠ Ġreturn Ġrun Write Action And Wait Ġ{ ĊĠĠĠĠĠ ĠV fs Util . create Directory If Missing ( sdk . home Directory !!. parent . parent , Ġrelative Path ) ĊĠĠĠ Ġ}. also Ġ{ Ġdelete On Tear Down ( it ) Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun Ġdelete On Tear Down ( file : ĠVirtual File ) Ġ{ ĊĠĠĠ ĠDis poser . register ( project Model . project ) Ġ{ ĠV fs TestUtil . delete File ( file ) Ġ} ĊĠ Ġ} Ċ }