From 563b057a4dbc8fcc1d0f771e41108b63c450a2b8 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Fri, 5 Mar 2010 12:49:54 +0100 Subject: [PATCH] Updated copyright year; fix nntp newsserver test --- tests/__init__.py | 20 +++++++++++++++----- tests/checker/__init__.py | 2 +- tests/checker/test_error.py | 2 +- tests/checker/test_ftp.py | 2 +- tests/checker/test_http.py | 2 +- tests/checker/test_https.py | 2 +- tests/checker/test_mail.py | 2 +- tests/checker/test_news.py | 16 ++++++++-------- tests/test_clamav.py | 2 +- tests/test_containers.py | 2 +- tests/test_cookies.py | 2 +- tests/test_decorators.py | 2 +- tests/test_filenames.py | 2 +- tests/test_gui.py | 2 +- tests/test_network.py | 2 +- tests/test_parser.py | 2 +- tests/test_po.py | 2 +- tests/test_robotparser.py | 2 +- tests/test_robotstxt.py | 2 +- tests/test_strformat.py | 2 +- tests/test_url.py | 2 +- tests/test_urlbuild.py | 2 +- 22 files changed, 43 insertions(+), 33 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 9d2047c4..40a8580e 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2005-2009 Bastian Kleineidam +# Copyright (C) 2005-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -138,16 +138,26 @@ need_proxy = _need_func(has_proxy, "proxy") @memoized -def has_newsserver (): +def has_newsserver (server): try: import nntplib - nntp = nntplib.NNTP(NNTP_SERVER, usenetrc=False) + nntp = nntplib.NNTP(server, usenetrc=False) nntp.close() return True - except: + except StandardError: return False -need_newsserver = _need_func(has_newsserver, "newsserver") + +def need_newsserver (server): + """Decorator skipping test if newsserver is not available.""" + def check_func (func): + def newfunc (*args, **kwargs): + if not has_newsserver(server): + raise SkipTest("Newsserver `%s' is not available" % server) + return func(*args, **kwargs) + newfunc.func_name = func.func_name + return newfunc + return check_func @memoized diff --git a/tests/checker/__init__.py b/tests/checker/__init__.py index 3a7620b8..fceb5a50 100644 --- a/tests/checker/__init__.py +++ b/tests/checker/__init__.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/checker/test_error.py b/tests/checker/test_error.py index c0d74155..9284d6a6 100644 --- a/tests/checker/test_error.py +++ b/tests/checker/test_error.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/checker/test_ftp.py b/tests/checker/test_ftp.py index 83618ab9..97396a1c 100644 --- a/tests/checker/test_ftp.py +++ b/tests/checker/test_ftp.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/checker/test_http.py b/tests/checker/test_http.py index 8e0dd04c..be0e18f5 100644 --- a/tests/checker/test_http.py +++ b/tests/checker/test_http.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/checker/test_https.py b/tests/checker/test_https.py index 9ac3f74a..a467fc5f 100644 --- a/tests/checker/test_https.py +++ b/tests/checker/test_https.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/checker/test_mail.py b/tests/checker/test_mail.py index 030c1ea7..a7119155 100644 --- a/tests/checker/test_mail.py +++ b/tests/checker/test_mail.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/checker/test_news.py b/tests/checker/test_news.py index 67c4a024..acb089b6 100644 --- a/tests/checker/test_news.py +++ b/tests/checker/test_news.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -35,7 +35,7 @@ class TestNews (LinkCheckTest): def newstest (self, url, resultlines): self.direct(url, resultlines) - @need_newsserver + @need_newsserver(NNTP_SERVER) def test_news_without_host (self): # news testing url = u"news:comp.os.linux.misc" @@ -58,7 +58,7 @@ class TestNews (LinkCheckTest): ] self.newstest(url, resultlines) - @need_newsserver + @need_newsserver(NNTP_SERVER) def test_snews_with_group (self): url = u"snews:de.comp.os.unix.linux.misc" nurl = self.norm(url) @@ -72,7 +72,7 @@ class TestNews (LinkCheckTest): ] self.newstest(url, resultlines) - @need_newsserver + @need_newsserver(NNTP_SERVER) def test_illegal_syntax (self): # illegal syntax url = u"news:§$%&/´`(§%" @@ -87,7 +87,7 @@ class TestNews (LinkCheckTest): ] self.newstest(url, resultlines) - @need_newsserver + @need_newsserver(NNTP_SERVER) @limit_time(NNTP_TIMEOUT_SECS, skip=True) def test_nntp_with_host (self): url = u"nntp://%s/comp.lang.python" % NNTP_SERVER @@ -101,7 +101,7 @@ class TestNews (LinkCheckTest): ] self.newstest(url, resultlines) - @need_newsserver + @need_newsserver(NNTP_SERVER) @limit_time(NNTP_TIMEOUT_SECS, skip=True) def test_article_span (self): url = u"nntp://%s/comp.lang.python/1-5" % NNTP_SERVER @@ -115,7 +115,7 @@ class TestNews (LinkCheckTest): ] self.newstest(url, resultlines) - @need_newsserver + @need_newsserver(NNTP_SERVER) def test_article_span_no_host (self): url = u"news:comp.lang.python/1-5" resultlines = [ @@ -127,7 +127,7 @@ class TestNews (LinkCheckTest): ] self.newstest(url, resultlines) - @need_newsserver + @need_newsserver(NNTP_SERVER) @limit_time(NNTP_TIMEOUT_SECS, skip=True) def test_host_no_group (self): url = u"nntp://%s/" % NNTP_SERVER diff --git a/tests/test_clamav.py b/tests/test_clamav.py index 52f65bb8..96d052a9 100644 --- a/tests/test_clamav.py +++ b/tests/test_clamav.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2006-2009 Bastian Kleineidam +# Copyright (C) 2006-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_containers.py b/tests/test_containers.py index 893cb601..e2df08b2 100644 --- a/tests/test_containers.py +++ b/tests/test_containers.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_cookies.py b/tests/test_cookies.py index 2b6a9a86..728323f1 100644 --- a/tests/test_cookies.py +++ b/tests/test_cookies.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2005-2009 Bastian Kleineidam +# Copyright (C) 2005-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_decorators.py b/tests/test_decorators.py index ee03957f..fd74d63a 100644 --- a/tests/test_decorators.py +++ b/tests/test_decorators.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2005-2009 Bastian Kleineidam +# Copyright (C) 2005-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_filenames.py b/tests/test_filenames.py index 4eec115a..0d9bba22 100644 --- a/tests/test_filenames.py +++ b/tests/test_filenames.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_gui.py b/tests/test_gui.py index b8eaec9f..11d2f23b 100644 --- a/tests/test_gui.py +++ b/tests/test_gui.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2009 Bastian Kleineidam +# Copyright (C) 2009-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_network.py b/tests/test_network.py index 8ee4b9f5..bfe88d30 100644 --- a/tests/test_network.py +++ b/tests/test_network.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2008-2009 Bastian Kleineidam +# Copyright (C) 2008-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_parser.py b/tests/test_parser.py index a1ec54a4..f67faf82 100644 --- a/tests/test_parser.py +++ b/tests/test_parser.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_po.py b/tests/test_po.py index a3ee92da..e1e7977a 100644 --- a/tests/test_po.py +++ b/tests/test_po.py @@ -1,6 +1,6 @@ # -*- coding: iso-8859-1 -*- # Copyright (C) 2005 Joe Wreschnig -# Copyright (C) 2005-2009 Bastian Kleineidam +# Copyright (C) 2005-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_robotparser.py b/tests/test_robotparser.py index 52b5db88..488e8619 100644 --- a/tests/test_robotparser.py +++ b/tests/test_robotparser.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_robotstxt.py b/tests/test_robotstxt.py index d7739bc2..2b672a80 100644 --- a/tests/test_robotstxt.py +++ b/tests/test_robotstxt.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2006-2009 Bastian Kleineidam +# Copyright (C) 2006-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_strformat.py b/tests/test_strformat.py index 1d895526..72faffaf 100644 --- a/tests/test_strformat.py +++ b/tests/test_strformat.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_url.py b/tests/test_url.py index 75250855..c8c22a7c 100644 --- a/tests/test_url.py +++ b/tests/test_url.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tests/test_urlbuild.py b/tests/test_urlbuild.py index f0deae36..452cb304 100644 --- a/tests/test_urlbuild.py +++ b/tests/test_urlbuild.py @@ -1,5 +1,5 @@ # -*- coding: iso-8859-1 -*- -# Copyright (C) 2004-2009 Bastian Kleineidam +# Copyright (C) 2004-2010 Bastian Kleineidam # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by