Git Product home page Git Product logo

pymol-testing's Introduction

PyMOL Testing Framework

This is a python unittest based testing framework for PyMOL.

Notice: "gui" tests currently don't work with PyMOL 2.x, tests should be run with "pymol -c ...".

How to Run Tests

From the system command line:

pymol -cq /path/to/pymol-testing/runall.pml

From the pymol command line:

PyMOL> run /path/to/pymol-testing/testing.py
PyMOL> run_testfiles path/to/*.py

How to write Tests

A test is a method of a pymol.testing.PyMOLTestCase subclass and is named
with a "test" prefix. Test files go into subdirectories like "api/" or "performance/". Each test method will start

  • with a clean PyMOL session (does reinitialize)
  • from the directory of its file (does os.chdir)

Decorators

  • @testing.requires(keyword): Takes one or more keywords and skips the test, if the requirement is not met. Valid keywords include: gui, incentive, network, no_run_all, multicore
  • @testing.foreach(args1, args2, ...): Decorates a test method which takes arguments

Context Managers

  • PyMOLTestCase.timing(max=sec): Gives feedback on running time and makes the test fail if it takes longer than max seconds.
  • PyMOLTestCase.mktemp(): Generates a temporary file name and deletes the file at context exit.

Assertion Methods

In addition to the standard assertion methods of the unittest.TestCase class, these assertion methods are currently available:

  • assertImageEqual(img1, img2=None, delta=0): Takes two images (as filenames, PIL objects or numpy arrays). If only one image is given, grab the current PyMOL scene as second imagae
  • assertImageHasColor(color, img=None, delta=0): Takes a color name, RGB or RGBA color tuple and an image (or grab the current scene) and check if it contains the given color
  • assertImageHasNotColor
  • assertImageHasTransparency
  • assertImageHasNoTransparency
  • assertColorEqual
  • assertArrayEqual
  • assertArrayNotEqual

Code Example

from pymol import cmd, testing, stored

class TestSomething(testing.PyMOLTestCase):

    def testFoo(self):
        cmd.fragment('ala')
        cmd.show_as('sticks')
        cmd.orient()
        self.assertImageEqual('ref-foo.png')

    @testing.requires('gui')
    def testBar(self):
        cmd.some_opengl_feature()

pymol-testing's People

Contributors

inchoate avatar jarrettsjohnson avatar simonkeng avatar speleo3 avatar tstewdev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pymol-testing's Issues

Fix OpenGL rendering tests

With the old GLUT GUI, tests could render an image on screen, write it to disc (with cmd.png()) and check the result. This doesn't work anymore with the PyQt GUI. Currently, tests only work headless (pymol -c ...). It would be great to find a way to test on-screen rendering with the PyQt GUI.

`--no-undo` tests don't work with PyMOL 2.5

The runall.pml script currently runs tests with --offline --no-mmlibs --no-undo. Removing these flags makes 9 tests fail with PyMOL 2.5.6.

6 of these failures come from --no-undo and these tests seem unsupported by any modern PyMOL version.

FAIL: test (tests/jira/PYMOL-1276_py.Test1276)
FAIL: testUndoAfterRemoveAtomOnDiscrete__0 (tests/jira/PYMOL-1697_py.TestPYMOL1697)
FAIL: testUndoAfterRemoveAtomOnDiscrete__1 (tests/jira/PYMOL-1697_py.TestPYMOL1697)
FAIL: testAtomLevelSettingsOnRemove (tests/jira/PYMOL-1567_py.TestPYMOL1567)
FAIL: testAtomLevelSettingsOnRemove2 (tests/jira/PYMOL-1567_py.TestPYMOL1567)
FAIL: testAtomStateLevelSettingsOnRemove (tests/jira/PYMOL-1567_py.TestPYMOL1567)

I suggest to either fix those tests for the new undo system, or remove them.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.