简体   繁体   中英

Failed build of Python project in Travis CI with unclear message

I'm learning "by doing" Python (and some libraries) with a small personal project.

I have been working with a Minimal Product Viable approach, then I'm negleting some best pratices about the file and directory organization.

Furthermore I use this occasion to learn pytest (I used to test with unittest library) and Travis for the continous integration.

I created a specific branch to test and consolidate my configuration in travis file, but after some test I'm blocked.

With this configuration

language: python
#python version
python: 3.8.6 
#define dependencsy
install:
  - pip install -r requirements.txt
# put testing framework
script: pytest
# allowed only these branch
branches:
  only:
  - master
  - develop
  - join-travis

I receive this error :

tests/test_NumberDays.py:61:


tests/numberdays.py:20: in init

self.log = PersonalLogging() tests/personalLogging.py:11: in init

logging.config.fileConfig("config-log.ini", disable_existing_loggers=False)

/opt/python/3.8.6/lib/python3.8/logging/config.py:71: in fileConfig

formatters = _create_formatters(cp) /opt/python/3.8.6/lib/python3.8/logging/config.py:104: in

_create_formatters

flist = cp["formatters"]["keys"]


self = <configparser.ConfigParser object at 0x7f845ff8e0a0>, key = 'formatters'

def getitem (self, key):

if key != self.default_section and not self.has_section(key):

raise KeyError(key) E KeyError: 'formatters'

/opt/python/3.8.6/lib/python3.8/configparser.py:960: KeyError

_______________________ ERROR at setup of testRunningOK ________________________

@pytest.fixture

def temporalRange () :

I think the problem of KeyError: 'formatters' is :

logging.config.fileConfig("config-log.ini", disable_existing_loggers=False)

I create a personal logging class ( PersonalLogging ) that incapsulate the standard logging class and the ini config file is in the same directory of the other classes (ND I know, It s horrible, in the future I will correct the structure of the project: guys, do not take my example or your Team Leader will fire you at work ^__^).

Now I have two problems:

  1. If my hypothesis is correct, how I an fix it and have a successfull build?
  2. If my hypothesis is uncorrect, what are (1) the correct explenation and (2) the solution?

Thank in advance

Problem solved.

For same cause that I don't remember, I changed the name of file and pushed without testing the project with pytest .

Then, Travis did'nt find the config file of logging.

In local, after running the project, I had the same error ( KeyError in formatters): the problem is the unreadable file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM