Am 27. November 2010 17:52 schrieb Iustin Pop <[email protected]>:
> --- a/test/ganeti.utils_unittest.py
> +++ b/test/ganeti.utils_unittest.py
> @@ -363,6 +363,19 @@ class TestRunCmd(testutils.GanetiTestCase):
>     self.failUnlessEqual(RunCmd(["env"], reset_env=True,
>                                 env={"FOO": "bar",}).stdout.strip(), 
> "FOO=bar")
>
> +  def testNoFork(self):
> +    """Test that nofork raise an error"""
> +    utils.no_fork = True

Please add an “assert not utils.no_fork” before this.

> +    try:
> +      self.assertRaises(errors.ProgrammerError, RunCmd, ["true"])
> +    finally:
> +      utils.no_fork = False

> […]
> +  def testMissingDirectory(self):
> +    self.assertEqual(RunParts("/no/such/directory"), [])

Please use “utils.PathJoin(self.rundir, "no/such/directory")”. Not
that I expect the above path to exist, but using a temporary directory
ensures it doesn't.

> -  def test(self):
> +  def testSingleFile(self):
>     self.assertEqual(utils._FingerprintFile(self.tmpfile.name),
> -                     "da39a3ee5e6b4b0d3255bfef95601890afd80709")
> +                     self.results[self.tmpfile.name])
> +
> +    self.assertEqual(utils._FingerprintFile("/no/such/file"), None)
>
> -    utils.WriteFile(self.tmpfile.name, data="Hello World\n")
> +  def testBigFile(self):
> +    self.tmpfile.write("A" * 8192)

Shouldn't you at least call “self.tmpfile.flush” here?

> +  def testTimes(self):
> +    f = self.tfile.name
> +    for at, mt in [(0, 0), (1000, 1000), (2000, 3000),
> +                   (int(time.time()), 5000)]:
> +      utils.WriteFile(f, data="hello", atime=at, mtime=mt)
> +      st = os.stat(f)
> +      self.assertEqual(st.st_atime, at)
> +      self.assertEqual(st.st_mtime, mt)
> +
> +
> +  def testNoClose(self):

One empty line at class level.

Michael

Reply via email to