Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_macurl2path.py @ 87690:66c1c9f32567 default tip
Add use_weakref option to functools.lru_cache
The use_weakref option makes lru_cache create weak references to the function
arguments when creating the cache key, which prevents them from staying in the
memory forever even after all other references to them are gone.
This is a proof of concept for http://bugs.python.org/issue19859
| author | Radomir Dopieralski <devel@sheep.art.pl> |
|---|---|
| date | Tue, 03 Dec 2013 16:02:48 +0100 |
| parents | 06b9a9e75a6c |
| children |
| rev | line source |
|---|---|
|
86596
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
1 import macurl2path |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
2 import unittest |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
3 |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
4 class MacUrl2PathTestCase(unittest.TestCase): |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
5 def test_url2pathname(self): |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
6 self.assertEqual(":index.html", macurl2path.url2pathname("index.html")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
7 self.assertEqual(":bar:index.html", macurl2path.url2pathname("bar/index.html")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
8 self.assertEqual("foo:bar:index.html", macurl2path.url2pathname("/foo/bar/index.html")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
9 self.assertEqual("foo:bar", macurl2path.url2pathname("/foo/bar/")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
10 self.assertEqual("", macurl2path.url2pathname("/")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
11 self.assertRaises(RuntimeError, macurl2path.url2pathname, "http://foo.com") |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
12 self.assertEqual("index.html", macurl2path.url2pathname("///index.html")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
13 self.assertRaises(RuntimeError, macurl2path.url2pathname, "//index.html") |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
14 self.assertEqual(":index.html", macurl2path.url2pathname("./index.html")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
15 self.assertEqual(":index.html", macurl2path.url2pathname("foo/../index.html")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
16 self.assertEqual("::index.html", macurl2path.url2pathname("../index.html")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
17 |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
18 def test_pathname2url(self): |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
19 self.assertEqual("drive", macurl2path.pathname2url("drive:")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
20 self.assertEqual("drive/dir", macurl2path.pathname2url("drive:dir:")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
21 self.assertEqual("drive/dir/file", macurl2path.pathname2url("drive:dir:file")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
22 self.assertEqual("drive/file", macurl2path.pathname2url("drive:file")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
23 self.assertEqual("file", macurl2path.pathname2url("file")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
24 self.assertEqual("file", macurl2path.pathname2url(":file")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
25 self.assertEqual("dir", macurl2path.pathname2url(":dir:")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
26 self.assertEqual("dir/file", macurl2path.pathname2url(":dir:file")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
27 self.assertRaises(RuntimeError, macurl2path.pathname2url, "/") |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
28 self.assertEqual("dir/../file", macurl2path.pathname2url("dir::file")) |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
29 |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
30 if __name__ == "__main__": |
|
06b9a9e75a6c
Increase the coverage of macurl2path. Patch by Colin Williams.
Senthil Kumaran <senthil@uthcode.com>
parents:
diff
changeset
|
31 unittest.main() |
