• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

TheKevJames / coveralls-python / 36ccccef-eea6-4e8d-9965-1fb2bf22a852

26 Apr 2024 12:52PM UTC coverage: 90.893%. Remained the same
36ccccef-eea6-4e8d-9965-1fb2bf22a852

push

circleci

TheKevJames
feat(compat): drop support for python 3.7

And migrate to poetry for package management.

138 of 157 branches covered (87.9%)

Branch coverage included in aggregate %.

6 of 6 new or added lines in 2 files covered. (100.0%)

6 existing lines in 2 files now uncovered.

381 of 414 relevant lines covered (92.03%)

5.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.24
/coveralls/cli.py
1
"""
2
Publish coverage results online via coveralls.io.
3

4
Puts your coverage results on coveralls.io for everyone to see.
5

6
This tool makes custom reports for data generated by coverage.py package and
7
sends it to the coveralls.io service API.
8

9
All Python files in your coverage analysis are posted to this service along
10
with coverage stats, so please make sure you're not ruining your own security!
11

12
Usage:
13
    coveralls [options]
14
    coveralls debug [options]
15

16
    Debug mode doesn't send anything, just outputs json to stdout. It also
17
    forces verbose output. Please use debug mode when submitting bug reports.
18

19
Global options:
20
    --service=<name>  Provide an alternative service name to submit.
21
    --rcfile=<file>   Specify configuration file. [default: .coveragerc]
22
    --basedir=<dir>   Base directory that is removed from reported paths.
23
    --output=<file>   Write report to file. Doesn't send anything.
24
    --srcdir=<dir>    Source directory added to reported paths.
25
    --submit=<file>   Upload a previously generated file.
26
    --merge=<file>    Merge report from file when submitting.
27
    --finish          Finish parallel jobs.
28
    -h --help         Display this help.
29
    -v --verbose      Print extra info, always enabled when debugging.
30

31
Example:
32
-------
33
    $ coveralls
34
    Submitting coverage to coveralls.io...
35
    Coverage submitted!
36
    Job #38.1
37
    https://coveralls.io/jobs/92059
38
"""
39
import importlib.metadata
6✔
40
import logging
6✔
41
import sys
6✔
42

43
import docopt
6✔
44

45
from .api import Coveralls
6✔
46
from .exception import CoverallsException
6✔
47

48

49
log = logging.getLogger('coveralls')
6✔
50

51

52
def main(argv=None):
6✔
53
    # pylint: disable=too-complex
54
    version = importlib.metadata.version('coveralls')
6✔
55
    options = docopt.docopt(__doc__, argv=argv, version=version)
6✔
56
    if options['debug']:
6✔
57
        options['--verbose'] = True
6✔
58

59
    level = logging.DEBUG if options['--verbose'] else logging.INFO
6✔
60
    log.addHandler(logging.StreamHandler())
6✔
61
    log.setLevel(level)
6✔
62

63
    token_required = not options['debug'] and not options['--output']
6✔
64

65
    try:
6✔
66
        coverallz = Coveralls(
6✔
67
            token_required,
68
            config_file=options['--rcfile'],
69
            service_name=options['--service'],
70
            base_dir=options.get('--basedir') or '',
71
            src_dir=options.get('--srcdir') or '',
72
        )
73

74
        if options['--merge']:
6!
UNCOV
75
            coverallz.merge(options['--merge'])
×
76

77
        if options['debug']:
6✔
78
            log.info('Testing coveralls-python...')
6✔
79
            coverallz.wear(dry_run=True)
6✔
80
            return
6✔
81

82
        if options['--output']:
6✔
83
            log.info('Write coverage report to file...')
6✔
84
            coverallz.save_report(options['--output'])
6✔
85
            return
6✔
86

87
        if options['--submit']:
6✔
88
            with open(options['--submit']) as report_file:
6✔
89
                coverallz.submit_report(report_file.read())
6✔
90
            return
6✔
91

92
        if options['--finish']:
6✔
93
            log.info('Finishing parallel jobs...')
6✔
94
            coverallz.parallel_finish()
6✔
95
            log.info('Done')
6✔
96
            return
6✔
97

98
        log.info('Submitting coverage to coveralls.io...')
6✔
99
        result = coverallz.wear()
6✔
100

101
        log.info('Coverage submitted!')
6✔
102
        log.debug(result)
6✔
103
        if result:
6!
104
            log.info(result.get('message'))
6✔
105
            log.info(result.get('url'))
6✔
106
    except KeyboardInterrupt:  # pragma: no cover
107
        log.info('Aborted')
108
    except CoverallsException as e:
6✔
109
        log.exception('Error running coveralls: %s', e)
6✔
110
        sys.exit(1)
6✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc