Skip to content

Commit

Permalink
Migrate modules tests to new test infra
Browse files Browse the repository at this point in the history
  • Loading branch information
jecisc committed Sep 2, 2024
1 parent 2cd511c commit 50740c5
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 79 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,46 @@
Class {
#name : 'FamixPythonAbstractImporterTest',
#superclass : 'TestCase',
#instVars : [
'importer'
],
#category : 'Famix-Python-Importer-Tests',
#package : 'Famix-Python-Importer-Tests'
}

{ #category : 'accessing' }
FamixPythonAbstractImporterTest >> classNamed: aName [

^ self model allClasses detect: [ :class | class name = aName ]
]

{ #category : 'accessing' }
FamixPythonAbstractImporterTest >> functionNamed: aName [

^ self model allFunctions detect: [ :function | function name = aName ]
]

{ #category : 'accessing' }
FamixPythonAbstractImporterTest >> importNamed: aName [

^ self model allImports detect: [ :import | import entityName = aName ]
]

{ #category : 'accessing' }
FamixPythonAbstractImporterTest >> model [
self subclassResponsibility
]

{ #category : 'running' }
FamixPythonAbstractImporterTest >> moduleName [
^ 'sprite_collect_blocks'


]

{ #category : 'accessing' }
FamixPythonAbstractImporterTest >> moduleNamed: aName [

^ self model allModules detect: [ :module | module name = aName ]
]

{ #category : 'running' }
FamixPythonAbstractImporterTest >> setUp [

Expand Down
60 changes: 2 additions & 58 deletions src/Famix-Python-Importer-Tests/FamixPythonImporterTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ Class {
'fileSystem',
'file',
'pyDoc2',
'file2'
'file2',
'importer'
],
#category : 'Famix-Python-Importer-Tests',
#package : 'Famix-Python-Importer-Tests'
Expand All @@ -18,13 +19,6 @@ FamixPythonImporterTest >> codeBig1 [
^ PythonParser parseFileWithErrors: (fileSystem / (self moduleName2 , '.py'))
]

{ #category : 'running' }
FamixPythonImporterTest >> moduleName [
^ 'sprite_collect_blocks'


]

{ #category : 'running' }
FamixPythonImporterTest >> moduleName2 [
^ 'sprite_collect_blocks_2'
Expand Down Expand Up @@ -570,17 +564,6 @@ FamixPythonImporterTest >> testIsModel [

]

{ #category : 'tests - module' }
FamixPythonImporterTest >> testKnowsItsModule [

| import module |
importer accept: pyDoc.
import := importer importNamed: 'pygame'.
module := importer moduleNamed: self moduleName.
self assert: import manualImportingEntity equals: module.

]

{ #category : 'tests - methods' }
FamixPythonImporterTest >> testMethod [

Expand Down Expand Up @@ -628,31 +611,6 @@ FamixPythonImporterTest >> testMethodWithParameter [
self assert: param isNotNil
]

{ #category : 'tests - module' }
FamixPythonImporterTest >> testModule [

| module |
importer accept: pyDoc.
module := importer moduleNamed: self moduleName.

self assert: module isNotNil.
self assert: module class equals: FamixPythonModule.
self assert: module name equals: self moduleName.

]

{ #category : 'tests - module' }
FamixPythonImporterTest >> testModuleKnowsItsImport [

| module |
importer accept: pyDoc.
module := importer moduleNamed: self moduleName.
self assert: module manualIncomingImports size equals: 2.
"does not work probably because of the bidirectional slots
self assert: module incomingImports size equals: 2."

]

{ #category : 'tests - lambdas' }
FamixPythonImporterTest >> testMultiFunctionsMultiLambdas [

Expand Down Expand Up @@ -840,17 +798,3 @@ class B:
assert: (importer model allWithType: FamixPythonClass) size
equals: 3
]

{ #category : 'tests - module' }
FamixPythonImporterTest >> testTwoSiblingImportsHaveTheSameModule [

| import module import2 |
importer accept: pyDoc.
import := importer importNamed: 'pygame'.
import2 := importer importNamed: 'random'.
module := importer moduleNamed: self moduleName.
self assert: import manualImportingEntity equals: module.
self assert: import2 manualImportingEntity equals: module.
self assert: import manualImportingEntity equals: import2 manualImportingEntity

]
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ FamixPythonImporterWithClassesTest class >> resources [
^ { FamixPythonWithClassesTestResource }
]

{ #category : 'accessing' }
FamixPythonImporterWithClassesTest >> classNamed: aName [

^ self model allClasses detect: [ :class | class name = aName ]
]

{ #category : 'accessing' }
FamixPythonImporterWithClassesTest >> model [
^ FamixPythonWithClassesTestResource current model
Expand Down Expand Up @@ -62,8 +56,50 @@ FamixPythonImporterWithClassesTest >> testClasses [
self assert: (self classNamed: 'Player') isNotNil
]

{ #category : 'tests - module' }
FamixPythonImporterWithClassesTest >> testKnowsItsModule [

| import module |
import := self importNamed: 'pygame'.
module := self moduleNamed: self moduleName.
self assert: import manualImportingEntity equals: module
]

{ #category : 'tests - module' }
FamixPythonImporterWithClassesTest >> testModule [

| module |
module := self moduleNamed: self moduleName.

self assert: module isNotNil.
self assert: module class equals: FamixPythonModule.
self assert: module name equals: self moduleName
]

{ #category : 'tests - module' }
FamixPythonImporterWithClassesTest >> testModuleKnowsItsImport [

| module |
module := self moduleNamed: self moduleName.
self assert: module manualIncomingImports size equals: 2
"does not work probably because of the bidirectional slots
self assert: module incomingImports size equals: 2."
]

{ #category : 'tests - classes' }
FamixPythonImporterWithClassesTest >> testRightNumberOfClasses [

self assert: self model numberOfClasses equals: 4
]

{ #category : 'tests - module' }
FamixPythonImporterWithClassesTest >> testTwoSiblingImportsHaveTheSameModule [

| import module import2 |
import := self importNamed: 'pygame'.
import2 := self importNamed: 'random'.
module := self moduleNamed: self moduleName.
self assert: import manualImportingEntity equals: module.
self assert: import2 manualImportingEntity equals: module.
self assert: import manualImportingEntity equals: import2 manualImportingEntity
]
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,11 @@ FamixPythonImporterWithFunctionsTest class >> resources [
^ { FamixPythonWithFunctionsTestResource }
]

{ #category : 'accessing' }
FamixPythonImporterWithFunctionsTest >> functionNamed: aName [

^ self model allFunctions detect: [ :function | function name = aName ]
]

{ #category : 'accessing' }
FamixPythonImporterWithFunctionsTest >> model [
^ FamixPythonWithFunctionsTestResource current model
]

{ #category : 'accessing' }
FamixPythonImporterWithFunctionsTest >> moduleNamed: aName [

^ self model allModules detect: [ :module | module name = aName ]
]

{ #category : 'tests - functions' }
FamixPythonImporterWithFunctionsTest >> testFunction [

Expand Down

0 comments on commit 50740c5

Please sign in to comment.