What should a Python project structure look like for Travis CI to find and run tests?

2024/9/21 2:50:34

I currently have a project with the following .travis.yml file:

language: python
install: "pip install tox"
script: "tox"

Locally, tox properly executes and runs 35 tests, but on Travis CI, it runs 0 tests.

More details: https://travis-ci.org/neverendingqs/pyiterable/builds/78954867

I also tried other ways, including:

language: python
python:- "2.6"- "2.7"- "3.2"- "3.3"- "3.4"- "3.5.0b3"- "3.5-dev"- "nightly"
# also fails with just `nosetest` and no `install` step
install: "pip install coverage unittest2"
script: "nosetests --with-coverage --cover-package=pyiterable"

They also could not find any tests.

My project structure is Like This:

- ...
- <module>
- tests (for the module)
- ...

Are the project/folders structured incorrectly?

Answer

There was nothing wrong with the folder structure.

It looks like the files on Travis CI are considered executable (logs from https://travis-ci.org/neverendingqs/pyiterable/builds/79049179):

nosetests --verbosity=3
nose.config: INFO: Ignoring files matching ['^\\.', '^_', '^setup\\.py$']
nose.selector: INFO: /home/travis/build/neverendingqs/pyiterable/LICENSE.txt is executable; skipped
nose.selector: INFO: /home/travis/build/neverendingqs/pyiterable/pyiterable/iterable.py is executable; skipped
nose.selector: INFO: /home/travis/build/neverendingqs/pyiterable/readme.md is executable; skipped
nose.selector: INFO: /home/travis/build/neverendingqs/pyiterable/setup.cfg is executable; skipped
nose.selector: INFO: /home/travis/build/neverendingqs/pyiterable/tox.ini is executable; skipped
nose.selector: INFO: /home/travis/build/neverendingqs/pyiterable/tests/test_iterable.py is executable; skipped

I changed tox.ini to run nosetests with --exe (nosetests --exe --with-coverage --cover-package=pyiterable), based on Run all Tests in Directory Using Nose. After fixing some non-related errors, I was able to get the tests to run @ https://travis-ci.org/neverendingqs/pyiterable/builds/79049983!

https://en.xdnf.cn/q/72100.html

Related Q&A

Having trouble building a Dns Packet in Python

Im trying to build a dns packet to send over a socket. I dont want to use any libraries because I want direct access to the socket variable that sends it. Whenever I send the DNS packet, wireshark says…

Element wise comparison between 1D and 2D array

Want to perform an element wise comparison between an 1D and 2D array. Each element of the 1D array need to be compared (e.g. greater) against the corresponding row of 2D and a mask will be created. He…

Jquery ajax post request not working

I have a simple form submission with ajax, but it keeps giving me an error. All the error says is "error". No code, no description. No nothing, when I alert it when it fails.Javascript with …

Why is the main() function not defined inside the if __main__?

You can often see this (variation a):def main():do_something()do_sth_else()if __name__ == __main__:main()And I am now wondering why not this (variation b):if __name__ == __main__:do_something()do_sth_e…

Using selenium inside gitlab CI/CD

Ive desperetaly tried to set a pytest pipeline CI/CD for my personal projet hosted by gitlab. I tried to set up a simple project with two basic files: file test_core.py, witout any other dependencies f…

VSCode issue with Python versions and environments from Jupyter Notebooks

Issue: I am having issues with the environment and version of Python not matching the settings in VSCode, and causing issues with the packages I am trying to use in Jupyter notebooks. I am using a Wind…

weighted covariance matrix in numpy

I want to compute the covariance C of n measurements of p quantities, where each individual quantity measurement is given its own weight. That is, my weight array W has the same shape as my quantity ar…

How to implement biased random function?

My question is about random.choice function. As we know, when we run random.choice([apple,banana]), it will return either apple or banana with equal probabilities, what if I want to return biased resul…

Finding minimum value for each level of a multi-index dataframe

I have a DataFrame that looks like this:data a b 1 1 0.12 0.23 0.3 2 1 0.52 0.63 0.7and I want to find the minimum value for each level of a ignoring the b level, so as an output Im l…

Count occurrences of a list of substrings in a pyspark df column

I want to count the occurrences of list of substrings and create a column based on a column in the pyspark df which contains a long string.Input: ID History1 USA|UK|IND|DEN|MAL|SWE|AUS2…