linkedin / pygradle

Using Gradle to build Python projects
https://github.com/linkedin/pygradle
Apache License 2.0
589 stars 147 forks source link

my unit tests are not being run #175

Open solidatyoungdevdotnet opened 6 years ago

solidatyoungdevdotnet commented 6 years ago

Everytime I try to run my build, the python code (all of it, both class and test class) gets compiled. I know this because if I introduce a syntax error into either the class or the test, the build will fail with a compile error. My "production" python classes are stored in src/main/python and my test classes are in src/test/python (they will fail the build if there is an error on a python file in src/test/python) Here is where everything goes sideways: NO MATTER WHERE I PUT THE PYTHON TEST SOURCE, PYGRADLE NEVER RUNS MY TESTS . I always get the following: ============================= test session starts ============================== platform darwin -- Python 2.7.10, pytest-2.9.1, py-1.4.29, pluggy-0.3.1 rootdir: /Users/user1/Documents/git/myproj, inifile: plugins: cov-2.2.1 collected 0 items

========================= no tests ran in 0.00 seconds ========================= WARNING: You did not write any tests!

Here is my build.gradle: `plugins { // newer version id "com.linkedin.python-sdist" version "0.4.9" } apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'jacoco'

group = 'com.mycompany' version = '1.0.0'

sourceCompatibility = 1.8 jar { manifest { attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version } }

repositories { mavenCentral() pyGradlePyPi() maven { url "http://ox.gluu.org/maven" }

}

dependencies { compile group: 'commons-collections', name: 'commons-collections', version: '3.2.2' compile 'org.springframework.boot:spring-boot-starter-security' compile 'org.springframework.boot:spring-boot-starter-web' compile 'org.springframework.boot:spring-boot-starter-thymeleaf:1.5.9.RELEASE' compile 'org.springframework.cloud:spring-cloud-starter-oauth2:1.2.1.RELEASE' compile 'org.springframework.security:spring-security-ldap:5.0.0.RELEASE' compile 'org.springframework.security:spring-security-jwt:1.0.8.RELEASE' compile 'org.springframework.data:spring-data-redis:1.7.7.RELEASE' compile 'redis.clients:jedis:2.8.2' compile 'org.xdi:oxTrust:1.3.2.Final' testCompile 'org.springframework.boot:spring-boot-starter-test:1.5.9.RELEASE' testCompile 'org.apache.httpcomponents:httpclient' testCompile group: 'junit', name: 'junit', version: '4.+' testCompile group: 'org.testng', name: 'testng', version: '5.14.10' python 'pypi:requests:2.9.1' test 'pypi:mock:1.3.0' }

test { systemProperties 'property': 'value' }

python { // testDir = file('src/test/python') } `

Any help would be greatly appreciated and I am running out of time on this project!

zvezdan commented 6 years ago

It seems that your code is structured in the way that Java code is usually structured in Gradle projects (src/main/java). However, the pygradle Python projects are expected to be structured as a standard Python package -- so Python developers can release them easily publicly and work in a code structure they learned to expect.

If you look into our examples/example-project directory here, you'll see that expected source-code structure: https://github.com/linkedin/pygradle/tree/master/examples/example-project As shown there you can use ./gradlew generateSetupPy to produce a setup.py in your Python project directory.

I hope this helps you. Let us know if you need more info.