Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pluralize() throws a type error for UNCOUNTABLES being NoneType #9

Open
archit opened this issue Oct 30, 2015 · 2 comments
Open

pluralize() throws a type error for UNCOUNTABLES being NoneType #9

archit opened this issue Oct 30, 2015 · 2 comments

Comments

@archit
Copy link

archit commented Oct 30, 2015

if I do a manual python shell session, I can pluralize() just fine. Similarly my application code when I run it, runs without any errors, exceptions. However when I run my unit tests for code that uses inflection.pluralize() I get the error

word = 'network'

    def pluralize(word):
        """
        Return the plural form of a word.

        Examples::

            >>> pluralize("post")
            "posts"
            >>> pluralize("octopus")
            "octopi"
            >>> pluralize("sheep")
            "sheep"
            >>> pluralize("CamelOctopus")
            "CamelOctopi"

        """
>       if not word or word.lower() in UNCOUNTABLES:
E       TypeError: argument of type 'NoneType' is not iterable

/usr/local/lib/python2.7/dist-packages/inflection.py:297: TypeError
3 failed, 50 passed in 0.14 seconds

When I run my tests using py.test --pdb, I'm unable to print any value for UNCOUNTABLES

word = 'networkTopology'

    def pluralize(word):
        """
        Return the plural form of a word.

        Examples::

            >>> pluralize("post")
            "posts"
            >>> pluralize("octopus")
            "octopi"
            >>> pluralize("sheep")
            "sheep"
            >>> pluralize("CamelOctopus")
            "CamelOctopi"

        """
>       if not word or word.lower() in UNCOUNTABLES:
E       TypeError: argument of type 'NoneType' is not iterable

/usr/local/lib/python2.7/dist-packages/inflection.py:297: TypeError
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> entering PDB >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
> /usr/local/lib/python2.7/dist-packages/inflection.py(297)pluralize()
-> if not word or word.lower() in UNCOUNTABLES:
(Pdb) UNCOUNTABLES
(Pdb) list
292             "sheep"
293             >>> pluralize("CamelOctopus")
294             "CamelOctopi"
295     
296         """
297  ->     if not word or word.lower() in UNCOUNTABLES:
298             return word
299         else:
300             for rule, replacement in PLURALS:
301                 if re.search(rule, word):
302                     return re.sub(rule, replacement, word)
(Pdb) 

I'm using inflection==0.3.1

@archit
Copy link
Author

archit commented Oct 30, 2015

Just an update, for a work around, I threw in from inflection import UNCOUNTABLES in my tests/__init__.py

@jpvanhal
Copy link
Owner

That seems really strange. Can you post minimal code to reproduce this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants