Skip to content

Commit

Permalink
Merge old-versionpy-8219: Remove old _version.py files.
Browse files Browse the repository at this point in the history
Fixes: twisted#8219
Author: hawkowl
Reviewer: mithrandi

git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@46855 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information
mithrandi committed Feb 25, 2016
1 parent 23fb808 commit 9bc27f6
Show file tree
Hide file tree
Showing 19 changed files with 136 additions and 102 deletions.
10 changes: 9 additions & 1 deletion twisted/conch/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,13 @@
Twisted Conch: The Twisted Shell. Terminal emulation, SSHv2 and telnet.
"""

from twisted.conch._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.conch", "__version__")
11 changes: 0 additions & 11 deletions twisted/conch/_version.py

This file was deleted.

10 changes: 9 additions & 1 deletion twisted/mail/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
Twisted Mail: Servers and clients for POP3, ESMTP, and IMAP.
"""

from twisted.mail._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.mail", "__version__")
11 changes: 0 additions & 11 deletions twisted/mail/_version.py

This file was deleted.

10 changes: 9 additions & 1 deletion twisted/names/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
Twisted Names: DNS server and client implementations.
"""

from twisted.names._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.names", "__version__")
11 changes: 0 additions & 11 deletions twisted/names/_version.py

This file was deleted.

10 changes: 9 additions & 1 deletion twisted/news/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
Twisted News: A NNTP-based news service.
"""

from twisted.news._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.news", "__version__")
11 changes: 0 additions & 11 deletions twisted/news/_version.py

This file was deleted.

14 changes: 9 additions & 5 deletions twisted/pair/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.


"""
Twisted Pair: The framework of your ethernet.
Low-level networking transports and utilities.
Expand All @@ -13,8 +10,15 @@
twisted.protocols.raw and twisted.protocols.rawudp.
Maintainer: Tommi Virtanen
"""

from twisted.pair._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.pair", "__version__")
11 changes: 0 additions & 11 deletions twisted/pair/_version.py

This file was deleted.

2 changes: 0 additions & 2 deletions twisted/python/dist3.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
"twisted.logger.test",
"twisted.names",
"twisted.names._rfc1982",
"twisted.names._version",
"twisted.names.cache",
"twisted.names.client",
"twisted.names.common",
Expand Down Expand Up @@ -225,7 +224,6 @@
"twisted.web._newclient",
"twisted.web._responses",
"twisted.web._stan",
"twisted.web._version",
"twisted.web.demo",
"twisted.web.error",
"twisted.web.guard",
Expand Down
10 changes: 9 additions & 1 deletion twisted/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,13 @@
Twisted Runner: Run and monitor processes.
"""

from twisted.runner._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.runner", "__version__")
11 changes: 0 additions & 11 deletions twisted/runner/_version.py

This file was deleted.

64 changes: 64 additions & 0 deletions twisted/test/test_twisted.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@
from __future__ import division, absolute_import

import sys
import twisted

from types import ModuleType, FunctionType

from twisted import _checkRequirements
from twisted.python.compat import _PY3
from twisted.python import reflect
from twisted.trial.unittest import TestCase, SkipTest


Expand Down Expand Up @@ -634,3 +637,64 @@ def install(self, version):
pass
else:
raise SkipTest("Mismatched system version of zope.interface")



class OldSubprojectDeprecationBase(TestCase):
"""
Base L{TestCase} for verifying each former subproject has a deprecated
C{__version__} and a removed C{_version.py}.
"""
subproject = None

def test_deprecated(self):
"""
The C{__version__} attribute of former subprojects is deprecated.
"""
module = reflect.namedAny("twisted.{}".format(self.subproject))
self.assertEqual(module.__version__, twisted.__version__)

warningsShown = self.flushWarnings()
self.assertEqual(1, len(warningsShown))
self.assertEqual(
"twisted.{}.__version__ was deprecated in Twisted 16.0.0: "
"Use twisted.__version__ instead.".format(self.subproject),
warningsShown[0]['message'])


def test_noversionpy(self):
"""
Former subprojects no longer have an importable C{_version.py}.
"""
with self.assertRaises(AttributeError):
reflect.namedAny(
"twisted.{}._version".format(self.subproject))



subprojects = ["mail", "conch", "runner", "web", "words", "names", "news",
"pair"]

for subproject in subprojects:

class SubprojectTestCase(OldSubprojectDeprecationBase):
"""
See L{OldSubprojectDeprecationBase}.
"""
subproject = subproject

newName = subproject.title() + "VersionDeprecationTests"

SubprojectTestCase.__name__ = newName
if _PY3:
SubprojectTestCase.__qualname__= ".".join(
OldSubprojectDeprecationBase.__qualname__.split()[0:-1] +
[newName])

globals().update({subproject.title() +
"VersionDeprecationTests": SubprojectTestCase})

del SubprojectTestCase
del newName

del OldSubprojectDeprecationBase
1 change: 1 addition & 0 deletions twisted/topfiles/8219.removal
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The __version__ attribute of former subprojects (conch, mail, names, news, pair, runner, web, and words) is deprecated in preference to the central twisted.__version__.
9 changes: 8 additions & 1 deletion twisted/web/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
a L{web client<twisted.web.client>}.
"""

from twisted.web._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.web", "__version__")
11 changes: 0 additions & 11 deletions twisted/web/_version.py

This file was deleted.

10 changes: 9 additions & 1 deletion twisted/words/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,13 @@
services.
"""

from twisted.words._version import version
from twisted.python.versions import Version
from twisted.python.deprecate import deprecatedModuleAttribute

from twisted._version import version
__version__ = version.short()

deprecatedModuleAttribute(
Version("Twisted", 16, 0, 0),
"Use twisted.__version__ instead.",
"twisted.words", "__version__")
11 changes: 0 additions & 11 deletions twisted/words/_version.py

This file was deleted.

0 comments on commit 9bc27f6

Please sign in to comment.