Mercurial > hg
comparison tests/hghave @ 43691:47ef023d0165
black: blacken scripts
These scripts weren't blackened. I found these as part of adding
script checking to test-check-format.t.
# skip-blame black
Differential Revision: https://phab.mercurial-scm.org/D7446
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 16 Nov 2019 11:53:47 -0800 |
parents | b1b35a9051c3 |
children | c102b704edb5 |
comparison
equal
deleted
inserted
replaced
43690:15cccbacd5ce | 43691:47ef023d0165 |
---|---|
11 import os | 11 import os |
12 import sys | 12 import sys |
13 | 13 |
14 checks = hghave.checks | 14 checks = hghave.checks |
15 | 15 |
16 | |
16 def list_features(): | 17 def list_features(): |
17 for name, feature in sorted(checks.items()): | 18 for name, feature in sorted(checks.items()): |
18 desc = feature[1] | 19 desc = feature[1] |
19 print(name + ':', desc) | 20 print(name + ':', desc) |
21 | |
20 | 22 |
21 def test_features(): | 23 def test_features(): |
22 failed = 0 | 24 failed = 0 |
23 for name, feature in checks.items(): | 25 for name, feature in checks.items(): |
24 check, _ = feature | 26 check, _ = feature |
27 except Exception as e: | 29 except Exception as e: |
28 print("feature %s failed: %s" % (name, e)) | 30 print("feature %s failed: %s" % (name, e)) |
29 failed += 1 | 31 failed += 1 |
30 return failed | 32 return failed |
31 | 33 |
34 | |
32 parser = optparse.OptionParser("%prog [options] [features]") | 35 parser = optparse.OptionParser("%prog [options] [features]") |
33 parser.add_option("--test-features", action="store_true", | 36 parser.add_option( |
34 help="test available features") | 37 "--test-features", action="store_true", help="test available features" |
35 parser.add_option("--list-features", action="store_true", | 38 ) |
36 help="list available features") | 39 parser.add_option( |
40 "--list-features", action="store_true", help="list available features" | |
41 ) | |
42 | |
37 | 43 |
38 def _loadaddon(): | 44 def _loadaddon(): |
39 if 'TESTDIR' in os.environ: | 45 if 'TESTDIR' in os.environ: |
40 # loading from '.' isn't needed, because `hghave` should be | 46 # loading from '.' isn't needed, because `hghave` should be |
41 # running at TESTTMP in this case | 47 # running at TESTTMP in this case |
47 return | 53 return |
48 | 54 |
49 sys.path.insert(0, path) | 55 sys.path.insert(0, path) |
50 try: | 56 try: |
51 import hghaveaddon | 57 import hghaveaddon |
58 | |
52 assert hghaveaddon # silence pyflakes | 59 assert hghaveaddon # silence pyflakes |
53 except BaseException as inst: | 60 except BaseException as inst: |
54 sys.stderr.write('failed to import hghaveaddon.py from %r: %s\n' | 61 sys.stderr.write( |
55 % (path, inst)) | 62 'failed to import hghaveaddon.py from %r: %s\n' % (path, inst) |
63 ) | |
56 sys.exit(2) | 64 sys.exit(2) |
57 sys.path.pop(0) | 65 sys.path.pop(0) |
66 | |
58 | 67 |
59 if __name__ == '__main__': | 68 if __name__ == '__main__': |
60 options, args = parser.parse_args() | 69 options, args = parser.parse_args() |
61 _loadaddon() | 70 _loadaddon() |
62 if options.list_features: | 71 if options.list_features: |