Skip to content

Latest commit

 

History

48 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pyrun

A plugin to run the unittests of the current buffer, at any granularity.

Table of Contents

Current state

Currently, the plugin only supports Django projects. It is capable to run:

  • all tests found in the current buffer
  • all tests of the 'closest' test class - this is decided based on the cursor position. In this mode, plugin runs all tests in the parent class under the cursor.
  • single test, under the cursor.

The output of the test run is presented in a floating window, centered in the middle of the screen.

Installation

return {
  {
    "danielNemeth19/pyrun.nvim",
    ft = "python",
    opts = {
      -- See Customization section for options
    },
  },
}

Configuration

Using defaults

The plugin is lazy loaded for python files. In case you want to use the plugin without any customization, the preferred config is:

return {
  {
    "danielNemeth19/pyrun.nvim",
    ft = "python",
    opts = {},
  },
}

Lazy will call the plugin's setup function in case an opts property is defined. An empty opts table means the defaults will be applied, since an empty table will be merged with the default config.

Alternatively, you can omit opts and set config to true -> Lazy would then call setup() (no arguments) for you:

return {
  {
    "danielNemeth19/pyrun.nvim",
    ft = "python",
    config = true
  }
}

Of course, calling setup() manually from config is also possible.

See lazy spec setup for more details.

Customization

Below all the configuration options currently supported.

  {
    keymaps = {
      run_all = "<leader>t",
      close_float = "q"
    },
    window_config = {
      relative = "win",
      width = 150,
      height = 40,
      style = "minimal",
      border = "single",
      title = "Running tests"
    }
  }

To change anything, just set the corresponding key in opts, e.g.:

return {
  {
    "danielNemeth19/pyrun.nvim",
    ft = "python",
    opts = {
      window_config = {
        title = "Custom title"
      }
    }
  }
}

Default Mappings:

Insert Normal Action
- <leader>ttt Runs all tests in file
- <leader>tt Runs all tests of parent test class*
- <leader>t Runs test under the cursor
- q Closes results window

The result of the test run is shown in a floating window. To close it, use q.

*In this mode runs all tests in the parent test class when the cursor is inside any test belonging to that class.

TODO:

  • implement treesitter targeting for def and class - Done
  • implement running closest test class - Done
  • implement running closest test case - Done
  • show test result output without buffering - Done
  • improve coloring of test result: pass should be green, failure should be red - Done
  • adds test class and test case validation
  • providing custom commands
  • open term in case breakpoint is used in test?
  • lazy loading based on *test*.py files
  • Logging, with custom command to open log file
  • metatables for inheritance?

Issue tracker

  • keymap seems to be "sticky" (stays in effect after leaving python buffer) - Done
  • float window positioned incorrectly if screen has splits open - Done

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages