comparison tests/test-extension.t @ 48876:42d2b31cee0b

tests: remove from __future__ from inline Python in tests This is no longer required since we require Python 3 and the linter no longer requires these statements. Differential Revision: https://phab.mercurial-scm.org/D12255
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 20 Feb 2022 15:28:44 -0700
parents af0b21d5a930
children 0583d7f0fdff
comparison
equal deleted inserted replaced
48875:6000f5b25c9b 48876:42d2b31cee0b
148 $ echo 'barfoo = !' >> $HGRCPATH 148 $ echo 'barfoo = !' >> $HGRCPATH
149 149
150 Check that extensions are loaded in phases: 150 Check that extensions are loaded in phases:
151 151
152 $ cat > foo.py <<EOF 152 $ cat > foo.py <<EOF
153 > from __future__ import print_function
154 > import os 153 > import os
155 > from mercurial import exthelper 154 > from mercurial import exthelper
156 > from mercurial.utils import procutil 155 > from mercurial.utils import procutil
157 > 156 >
158 > def write(msg): 157 > def write(msg):
293 $ mkdir $TESTTMP/libroot/mod 292 $ mkdir $TESTTMP/libroot/mod
294 $ touch $TESTTMP/libroot/mod/__init__.py 293 $ touch $TESTTMP/libroot/mod/__init__.py
295 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py 294 $ echo "s = 'libroot/mod/ambig.py'" > $TESTTMP/libroot/mod/ambig.py
296 295
297 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<NO_CHECK_EOF 296 $ cat > $TESTTMP/libroot/mod/ambigabs.py <<NO_CHECK_EOF
298 > from __future__ import absolute_import, print_function
299 > import ambig # should load "libroot/ambig.py" 297 > import ambig # should load "libroot/ambig.py"
300 > s = ambig.s 298 > s = ambig.s
301 > NO_CHECK_EOF 299 > NO_CHECK_EOF
302 $ cat > loadabs.py <<NO_CHECK_EOF 300 $ cat > loadabs.py <<NO_CHECK_EOF
303 > import mod.ambigabs as ambigabs 301 > import mod.ambigabs as ambigabs
309 ambigabs.s=libroot/ambig.py 307 ambigabs.s=libroot/ambig.py
310 $TESTTMP/a 308 $TESTTMP/a
311 309
312 #if no-py3 310 #if no-py3
313 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<NO_CHECK_EOF 311 $ cat > $TESTTMP/libroot/mod/ambigrel.py <<NO_CHECK_EOF
314 > from __future__ import print_function
315 > import ambig # should load "libroot/mod/ambig.py" 312 > import ambig # should load "libroot/mod/ambig.py"
316 > s = ambig.s 313 > s = ambig.s
317 > NO_CHECK_EOF 314 > NO_CHECK_EOF
318 $ cat > loadrel.py <<NO_CHECK_EOF 315 $ cat > loadrel.py <<NO_CHECK_EOF
319 > import mod.ambigrel as ambigrel 316 > import mod.ambigrel as ambigrel
338 > NO_CHECK_EOF 335 > NO_CHECK_EOF
339 $ cat > $TESTTMP/extroot/sub1/baz.py <<NO_CHECK_EOF 336 $ cat > $TESTTMP/extroot/sub1/baz.py <<NO_CHECK_EOF
340 > s = b'this is extroot.sub1.baz' 337 > s = b'this is extroot.sub1.baz'
341 > NO_CHECK_EOF 338 > NO_CHECK_EOF
342 $ cat > $TESTTMP/extroot/__init__.py <<NO_CHECK_EOF 339 $ cat > $TESTTMP/extroot/__init__.py <<NO_CHECK_EOF
343 > from __future__ import absolute_import
344 > s = b'this is extroot.__init__' 340 > s = b'this is extroot.__init__'
345 > from . import foo 341 > from . import foo
346 > def extsetup(ui): 342 > def extsetup(ui):
347 > ui.write(b'(extroot) ', foo.func(), b'\n') 343 > ui.write(b'(extroot) ', foo.func(), b'\n')
348 > ui.flush() 344 > ui.flush()
451 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs 447 $ mkdir -p $TESTTMP/extlibroot/recursedown/abs
452 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<NO_CHECK_EOF 448 $ cat > $TESTTMP/extlibroot/recursedown/abs/used.py <<NO_CHECK_EOF
453 > detail = b"this is extlibroot.recursedown.abs.used" 449 > detail = b"this is extlibroot.recursedown.abs.used"
454 > NO_CHECK_EOF 450 > NO_CHECK_EOF
455 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<NO_CHECK_EOF 451 $ cat > $TESTTMP/extlibroot/recursedown/abs/__init__.py <<NO_CHECK_EOF
456 > from __future__ import absolute_import
457 > from extlibroot.recursedown.abs.used import detail 452 > from extlibroot.recursedown.abs.used import detail
458 > NO_CHECK_EOF 453 > NO_CHECK_EOF
459 454
460 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy 455 $ mkdir -p $TESTTMP/extlibroot/recursedown/legacy
461 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<NO_CHECK_EOF 456 $ cat > $TESTTMP/extlibroot/recursedown/legacy/used.py <<NO_CHECK_EOF
465 > # legacy style (level == -1) import 460 > # legacy style (level == -1) import
466 > from extlibroot.recursedown.legacy.used import detail 461 > from extlibroot.recursedown.legacy.used import detail
467 > NO_CHECK_EOF 462 > NO_CHECK_EOF
468 463
469 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<NO_CHECK_EOF 464 $ cat > $TESTTMP/extlibroot/recursedown/__init__.py <<NO_CHECK_EOF
470 > from __future__ import absolute_import
471 > from extlibroot.recursedown.abs import detail as absdetail 465 > from extlibroot.recursedown.abs import detail as absdetail
472 > from .legacy import detail as legacydetail 466 > from .legacy import detail as legacydetail
473 > NO_CHECK_EOF 467 > NO_CHECK_EOF
474 468
475 Setup package that re-exports an attribute of its submodule as the same 469 Setup package that re-exports an attribute of its submodule as the same
479 $ mkdir -p $TESTTMP/extlibroot/shadowing 473 $ mkdir -p $TESTTMP/extlibroot/shadowing
480 $ cat > $TESTTMP/extlibroot/shadowing/used.py <<NO_CHECK_EOF 474 $ cat > $TESTTMP/extlibroot/shadowing/used.py <<NO_CHECK_EOF
481 > detail = b"this is extlibroot.shadowing.used" 475 > detail = b"this is extlibroot.shadowing.used"
482 > NO_CHECK_EOF 476 > NO_CHECK_EOF
483 $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<NO_CHECK_EOF 477 $ cat > $TESTTMP/extlibroot/shadowing/proxied.py <<NO_CHECK_EOF
484 > from __future__ import absolute_import
485 > from extlibroot.shadowing.used import detail 478 > from extlibroot.shadowing.used import detail
486 > NO_CHECK_EOF 479 > NO_CHECK_EOF
487 $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<NO_CHECK_EOF 480 $ cat > $TESTTMP/extlibroot/shadowing/__init__.py <<NO_CHECK_EOF
488 > from __future__ import absolute_import
489 > from .used import detail as used 481 > from .used import detail as used
490 > NO_CHECK_EOF 482 > NO_CHECK_EOF
491 483
492 Setup extension local modules to be imported with "absolute_import" 484 Setup extension local modules to be imported with "absolute_import"
493 feature. 485 feature.
512 504
513 $ cat > $TESTTMP/absextroot/relimportee.py <<NO_CHECK_EOF 505 $ cat > $TESTTMP/absextroot/relimportee.py <<NO_CHECK_EOF
514 > detail = b"this is absextroot.relimportee" 506 > detail = b"this is absextroot.relimportee"
515 > NO_CHECK_EOF 507 > NO_CHECK_EOF
516 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<NO_CHECK_EOF 508 $ cat > $TESTTMP/absextroot/xsub1/xsub2/relimporter.py <<NO_CHECK_EOF
517 > from __future__ import absolute_import
518 > from mercurial import pycompat 509 > from mercurial import pycompat
519 > from ... import relimportee 510 > from ... import relimportee
520 > detail = b"this relimporter imports %r" % ( 511 > detail = b"this relimporter imports %r" % (
521 > pycompat.bytestr(relimportee.detail)) 512 > pycompat.bytestr(relimportee.detail))
522 > NO_CHECK_EOF 513 > NO_CHECK_EOF
523 514
524 Setup modules, which actually import extension local modules at 515 Setup modules, which actually import extension local modules at
525 runtime. 516 runtime.
526 517
527 $ cat > $TESTTMP/absextroot/absolute.py << NO_CHECK_EOF 518 $ cat > $TESTTMP/absextroot/absolute.py << NO_CHECK_EOF
528 > from __future__ import absolute_import
529 > 519 >
530 > # import extension local modules absolutely (level = 0) 520 > # import extension local modules absolutely (level = 0)
531 > from absextroot.xsub1.xsub2 import used, unused 521 > from absextroot.xsub1.xsub2 import used, unused
532 > from absextroot.xsub1.xsub2.called import func 522 > from absextroot.xsub1.xsub2.called import func
533 > 523 >
537 > result.append(func()) 527 > result.append(func())
538 > return result 528 > return result
539 > NO_CHECK_EOF 529 > NO_CHECK_EOF
540 530
541 $ cat > $TESTTMP/absextroot/relative.py << NO_CHECK_EOF 531 $ cat > $TESTTMP/absextroot/relative.py << NO_CHECK_EOF
542 > from __future__ import absolute_import
543 > 532 >
544 > # import extension local modules relatively (level == 1) 533 > # import extension local modules relatively (level == 1)
545 > from .xsub1.xsub2 import used, unused 534 > from .xsub1.xsub2 import used, unused
546 > from .xsub1.xsub2.called import func 535 > from .xsub1.xsub2.called import func
547 > 536 >
557 > NO_CHECK_EOF 546 > NO_CHECK_EOF
558 547
559 Setup main procedure of extension. 548 Setup main procedure of extension.
560 549
561 $ cat > $TESTTMP/absextroot/__init__.py <<NO_CHECK_EOF 550 $ cat > $TESTTMP/absextroot/__init__.py <<NO_CHECK_EOF
562 > from __future__ import absolute_import
563 > from mercurial import registrar 551 > from mercurial import registrar
564 > cmdtable = {} 552 > cmdtable = {}
565 > command = registrar.command(cmdtable) 553 > command = registrar.command(cmdtable)
566 > 554 >
567 > # "absolute" and "relative" shouldn't be imported before actual 555 > # "absolute" and "relative" shouldn't be imported before actual
1923 Prohibit the use of unicode strings as the default value of options 1911 Prohibit the use of unicode strings as the default value of options
1924 1912
1925 $ hg init $TESTTMP/opt-unicode-default 1913 $ hg init $TESTTMP/opt-unicode-default
1926 1914
1927 $ cat > $TESTTMP/test_unicode_default_value.py << EOF 1915 $ cat > $TESTTMP/test_unicode_default_value.py << EOF
1928 > from __future__ import print_function
1929 > from mercurial import registrar 1916 > from mercurial import registrar
1930 > cmdtable = {} 1917 > cmdtable = {}
1931 > command = registrar.command(cmdtable) 1918 > command = registrar.command(cmdtable)
1932 > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]') 1919 > @command(b'dummy', [(b'', b'opt', u'value', u'help')], 'ext [OPTIONS]')
1933 > def ext(*args, **opts): 1920 > def ext(*args, **opts):