[PATCH hglib] test: fix a test regression after log behavior fix in mercurial

Matt Mackall mpm at selenic.com
Thu Apr 25 16:59:07 CDT 2013


On Fri, 2013-04-26 at 01:47 +0400, Alexander Plavin wrote:
> # HG changeset patch
> # User Alexander Plavin <me at aplavin.ru>
> # Date 1366926368 -14400
> #      Fri Apr 26 01:46:08 2013 +0400
> # Node ID 9c05d1ae50c047a9cfcf9246873a97ebad1a50a8
> # Parent  9324a89dd84e1562b87556a3b2788fdf04ba8179
> test: fix a test regression after log behavior fix in mercurial
> 
> hg log behavior on empty repositories changed, so modify test cases accordingly

If you look carefully at the Buildbot, you'll see that we're running
hglib against multiple versions of hg. They're intentionally not closely
coupled.

So the test here has to instead be more liberal somehow and accept both
types of errors or the code that's calling 'log' has to only generate
one. This latter may be slightly preferable.

> diff -r 9324a89dd84e -r 9c05d1ae50c0 tests/test-context.py
> --- a/tests/test-context.py	Tue Apr 23 22:11:26 2013 +0200
> +++ b/tests/test-context.py	Fri Apr 26 01:46:08 2013 +0400
> @@ -1,9 +1,10 @@
> +from hglib.error import CommandError
>  import common, hglib
>  from hglib import context
>  
>  class test_context(common.basetest):
>      def test_non_existent(self):
> -        self.assertRaises(ValueError, context.changectx, self.client, 'foo')
> +        self.assertRaises(CommandError, context.changectx, self.client, 'foo')
>  
>      def test_basic(self):
>          self.append('a', 'a')
> diff -r 9324a89dd84e -r 9c05d1ae50c0 tests/test-log.py
> --- a/tests/test-log.py	Tue Apr 23 22:11:26 2013 +0200
> +++ b/tests/test-log.py	Fri Apr 26 01:46:08 2013 +0400
> @@ -1,5 +1,6 @@
> +from hglib.error import CommandError
>  import common
> -import hglib
> +
>  
>  class test_log(common.basetest):
>      def test_basic(self):
> @@ -16,3 +17,9 @@
>  
>          self.assertEquals(revs[0], self.client.log('0')[0])
>          self.assertEquals(self.client.log(), self.client.log(files=['a']))
> +
> +    def test_errors(self):
> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'foo')
> +        self.append('a', 'a')
> +        self.client.commit('first', addremove=True)
> +        self.assertRaisesRegexp(CommandError, 'abort: unknown revision', self.client.log, 'bar')
> \ No newline at end of file
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list