Skip to content

Commit

Permalink
Add test to ensure that we do not duplicate stub packages
Browse files Browse the repository at this point in the history
When two modules import the same stub package, we should not duplicated them.
  • Loading branch information
jecisc committed Sep 24, 2024
1 parent 4665878 commit 0109425
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/Famix-Python-Importer-Tests/FamixPythonProject1Test.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ FamixPythonProject1Test >> testImportThatIsNotAtTheRootOfAFile [
self assert: import importedEntity equals: (self packageNamed: 'root2')
]

{ #category : 'tests - imports' }
FamixPythonProject1Test >> testImportTwoStubPackagesOfTheSameName [
"If two imports import a stub package of the same name, we should not produce multiple stubs."

| pyplot numpy |
self assert: (self model allPackages select: [ :package | package name = 'matplotlib' ]) size equals: 1.
self assert: (self model allPackages select: [ :package | package name = 'pyplot' ]) size equals: 1.
self assert: (self model allPackages select: [ :package | package name = 'numpy' ]) size equals: 1.

pyplot := self packageNamed: 'pyplot'.
numpy := self packageNamed: 'numpy'.

"We ensure that those two are imported by more than 1 module"
self assert: ((self moduleNamed: 'moduleAtRoot4') outgoingImports anySatisfy: [ :import | import importedEntity = pyplot ]).
self assert: ((self moduleNamed: 'moduleAtRoot4') outgoingImports anySatisfy: [ :import | import importedEntity = numpy ]).

self assert: ((self moduleNamed: 'moduleWithStubs') outgoingImports anySatisfy: [ :import | import importedEntity = pyplot ]).
self assert: ((self moduleNamed: 'moduleWithStubs') outgoingImports anySatisfy: [ :import | import importedEntity = numpy ])
]

{ #category : 'tests - imports' }
FamixPythonProject1Test >> testMethodImportsModule [

Expand Down

0 comments on commit 0109425

Please sign in to comment.