heavenshell / vim-pydocstring

Generate Python docstring to your Python source code.
BSD 3-Clause "New" or "Revised" License
337 stars 53 forks source link

Add tests and fix some issues #14

Closed letientai299 closed 7 years ago

letientai299 commented 7 years ago

This is my fisrt step to address #13. This includes:

I also fix 2 issues:

letientai299 commented 7 years ago

Perhaps you also want to enable Travis CI integration, since we now have tests. :smile:

heavenshell commented 7 years ago

Wow! awsome!! Thank you so much!! I'll look into it.

Could you add .travis.yml and test job to yml? I'm not familiar with vader. I want to run all tests at Travis-CI not local.

letientai299 commented 7 years ago

I tried integrate with Travis, and fail due to wrong indentation. The tests work just fine with both nvim (0.2.0-dev) and vim (7.4) on my machine (Ubuntu 16.10). But not on Travis (Vim 7.3). I also tried to installl and use nvim on Travis. Still no luck. I don't know why. :disappointed:

To be honest, this is the first time I try vader.

Perhaps, we could skip this integration for later, and focus on #13.

heavenshell commented 7 years ago

@letientai299 Thank you for working about this! Travis-CI Vim is too old and it's seems to we need install Vim from GitHub. I'll try it after your PR merged. But currently I've got errors 😢

I try to run your PR at my local Mac(running macOSX 10.11.6 and MacVim 8.0).

$ cd test
$ vim basic.vader
basic.vader|88 error| class Foo / Put cursor to def foo(self) / Execute Pydocstring on def foo(self) (#23)                                                      
Starting Vader: 1 suite(s), 8 case(s)
  Starting Vader: /path/to/vim-pydocstring/test/basic.vader
    (1/8) [  GIVEN] def foo
    (1/8) [EXECUTE]
    (1/8) [ EXPECT]
    (2/8) [  GIVEN] def foo with 1 param
    (2/8) [EXECUTE]
    (2/8) [ EXPECT]
    (3/8) [  GIVEN] def foo with 2 params
    (3/8) [EXECUTE]
    (3/8) [ EXPECT]
    (4/8) [  GIVEN] def foo with variadic params
    (4/8) [EXECUTE]
    (4/8) [ EXPECT]
    (5/8) [  GIVEN] class Foo
    (5/8) [EXECUTE]
    (5/8) [ EXPECT]
    (6/8) [  GIVEN] class Foo
    (6/8) [     DO] Put cursor to def foo(self)
    (6/8) [   THEN] Execute Pydocstring on def foo(self)
    (6/8) [   THEN] (X) Vim:E492: Not an editor command:   Pydocstring
      > /private/var/folders/wk/wtn88t9559j3zpqj_pwxzzh80000gn/T/vbu2wnr/5, line 1
    (6/8) [ EXPECT] (X)
      - Expected:
            class Foo(object):
                def foo(self):
                    """foo"""
                    pass

                def arg1(self, arg1):
                    pass
      - Got:
          # vim:set et sw=4 ts=4 tw=79:

          # Test def keyword
          #-------------------------------------------------------------------------------
          Given python (def foo):
              def foo():
                  pass

          Execute:
              Pydocstring

          Expect python:
              def foo():
                  """foo"""
                  pass

          Given python (def foo with 1 param):
              def foo(arg):
                  pass

          Execute:
              Pydocstring

          Expect python:
              def foo(arg):
                  """foo

                  :param arg:
                  """
                  pass

          Given python (def foo with 2 params):
              def foo(arg1, arg2):
                  pass

          Execute:
              Pydocstring

          Expect python:
              def foo(arg1, arg2):
                  """foo

                  :param arg1:
                  :param arg2:
                  """
                  pass

          Given python (def foo with variadic params):
              def foo(*arg):
                  pass

          Execute:
              Pydocstring
          Expect python:
              def foo(*arg):
                  """foo

                  :param *arg:
                  """
                  pass

          # Test class keyword
          #-------------------------------------------------------------------------------

          Given python (class Foo):
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass

          Execute:
              Pydocstring

          Expect python:
              class Foo(object):
                  """Foo"""
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass

          Given python (class Foo):
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass

          Do (Put cursor to def foo(self)):
              j

          Then Execute (Execute Pydocstring on def foo(self)):
              Pydocstring

          Expect python:
              class Foo(object):
                  def foo(self):
                      """foo"""
                      pass

                  def arg1(self, arg1):
                      pass

          Given python (class Foo):
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      pass

          Do (Put cursor to def arg1(self, arg1)):
              4j

          Then Execute (Execute Pydocstring on def arg1(self, arg1)):
              Pydocstring

          Expect python:
              class Foo(object):
                  def foo(self):
                      pass

                  def arg1(self, arg1):
                      """arg1

                      :param arg1:
                      """
                      pass

          # Test aync/await keyword
          #-------------------------------------------------------------------------------
          Given python (async def foo):
              async def foo():
                  pass

          Execute:
              Pydocstring

          Expect python:
              async def foo():
                  """foo"""
                  pass

    (7/8) [  GIVEN] class Foo
    (7/8) [     DO] Put cursor to def arg1(self, arg1)
    (7/8) [   THEN] Execute Pydocstring on def arg1(self, arg1)
    (7/8) [ EXPECT]
    (8/8) [  GIVEN] async def foo
    (8/8) [EXECUTE]
    (8/8) [ EXPECT]
  Success/Total: 7/8
Success/Total: 7/8 (assertions: 0/0)
Elapsed time: 0.224163 sec.

What should I do? I think I miss something 😢

letientai299 commented 7 years ago
    (6/8) [   THEN] (X) Vim:E492: Not an editor command:   Pydocstring

I think you have not enable Pydocstring on vader. files. To test Pydocstring isolately, I've created a minimul_vimrc which will source only vader.vim and the plugin. Please try to run the test with:

vim -Nu minimul_vimrc basic.vader
heavenshell commented 7 years ago

@letientai299 Thanks, finally I could ran tests. I requested you to change for run Vader in background.

heavenshell commented 7 years ago

@letientai299 Add changes(change run.sh and run-single-test-file.sh) and pushed to Master. Please pull from master.

Thank you so much to adding test!

heavenshell commented 7 years ago

@letientai299 Finally success to run Travis-ci integration. https://travis-ci.org/heavenshell/vim-pydocstring

I fixed run.sh and test/run-single-test-file.sh for Travis-CI.

letientai299 commented 7 years ago

Wow, so the trick is build vim itself to get the latest version.