tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

coverplug.py (607B)


      1 """Coverage plugin to add exclude lines based on the Python version."""
      2 
      3 import sys
      4 
      5 from coverage import CoveragePlugin
      6 
      7 
      8 class MyConfigPlugin(CoveragePlugin):
      9    def configure(self, config):
     10        opt_name = 'report:exclude_lines'
     11        exclude_lines = config.get_option(opt_name)
     12        # Python >= 3.6 has os.PathLike.
     13        if sys.version_info >= (3, 6):
     14            exclude_lines.append('pragma: >=36')
     15        else:
     16            exclude_lines.append('pragma: <=35')
     17        config.set_option(opt_name, exclude_lines)
     18 
     19 
     20 def coverage_init(reg, options):
     21    reg.add_configurer(MyConfigPlugin())