summary refs log tree commit diff stats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/tc_commandlist.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/test/tc_commandlist.py b/test/tc_commandlist.py
new file mode 100644
index 00000000..ed9b1bd7
--- /dev/null
+++ b/test/tc_commandlist.py
@@ -0,0 +1,54 @@
+if __name__ == '__main__': from __init__ import init; init()
+
+from unittest import TestCase, main
+from ranger.container.commandlist import CommandList as CL
+
+class Test(TestCase):
+	def assertKeyError(self, obj, key):
+		self.assertRaises(KeyError, obj.__getitem__, key)
+
+	def test_commandist(self):
+		cl = CL()
+		fnc = lambda arg: 1
+		dmy = cl.dummy_object
+
+		cl.bind(fnc, 'aaaa')
+		cl.rebuild_paths()
+
+		self.assertEqual(dmy, cl['a'])
+		self.assertEqual(dmy, cl['aa'])
+		self.assertEqual(dmy, cl['aaa'])
+		self.assertEqual(fnc, cl['aaaa'].execute)
+		self.assertKeyError(cl, 'aabb')
+		self.assertKeyError(cl, 'aaaaa')
+
+		cl.bind(fnc, 'aabb')
+		cl.rebuild_paths()
+
+		self.assertEqual(dmy, cl['a'])
+		self.assertEqual(dmy, cl['aa'])
+		self.assertEqual(dmy, cl['aab'])
+		self.assertEqual(fnc, cl['aabb'].execute)
+		self.assertEqual(dmy, cl['aaa'])
+		self.assertEqual(fnc, cl['aaaa'].execute)
+
+		cl.unbind('aabb')
+		cl.rebuild_paths()
+
+		self.assertEqual(dmy, cl['a'])
+		self.assertEqual(dmy, cl['aa'])
+		self.assertKeyError(cl, 'aabb')
+		self.assertKeyError(cl, 'aab')
+		self.assertEqual(dmy, cl['aaa'])
+		self.assertEqual(fnc, cl['aaaa'].execute)
+
+		hint_text = 'some tip blablablba'
+		cl.hint(hint_text, 'aa')
+		cl.rebuild_paths()
+
+		self.assertEqual(dmy, cl['a'])
+		self.assertEqual(hint_text, cl['aa'].text)
+		self.assertEqual(dmy, cl['aaa'])
+		self.assertEqual(fnc, cl['aaaa'].execute)
+
+if __name__ == '__main__': main()
Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/usr/bin/env zsh
# Copy binaries across mu directories for different students on a single
# server, so we only need to build them once.

cp -r $1/enumerate/enumerate $2/enumerate
cp -r $1/cleave/cleave $2/cleave
rm -rf $2/.build
cp -r $1/.build $2
cp -r $1/mu_bin $2
cd $2
./mu  # couple of things still get recompiled, but should now be quick