Mercurial > hg
annotate tests/test-match.py @ 34639:a568a46751b6
selectors2: do not use platform.system()
`platform.system()` may have a side effect spawning a shell executing
`uname -p`, which may print a warning when the current directory is removed:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
This patch changes selectors2 to test the `sys.platform` string, which is a
much safer way to detect Jython.
Jython's `sys.platform` looks like this:
Jython 2.7.1 (default:0df7adb1b397, Jun 30 2017, 19:02:43)
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_144
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.platform
'java1.8.0_144 ( ==linux2 for targets )'
Differential Revision: https://phab.mercurial-scm.org/D1018
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 11 Oct 2017 17:27:21 -0700 |
parents | 44bc181b9835 |
children | 987d3a4b989f |
rev | line source |
---|---|
33582
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
1 from __future__ import absolute_import |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
2 |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
3 import unittest |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
4 |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
5 import silenttestrunner |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
6 |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
7 from mercurial import ( |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
8 match as matchmod, |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
9 ) |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
10 |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
11 class NeverMatcherTests(unittest.TestCase): |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
12 |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
13 def testVisitdir(self): |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
14 m = matchmod.nevermatcher('', '') |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
15 self.assertFalse(m.visitdir('.')) |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
16 self.assertFalse(m.visitdir('dir')) |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
17 |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
18 if __name__ == '__main__': |
44bc181b9835
match: override visitdir() in nevermatcher to return False
Martin von Zweigbergk <martinvonz@google.com>
parents:
diff
changeset
|
19 silenttestrunner.main(__name__) |