Unverified Commit 6563234c authored by Bharath Ramsundar's avatar Bharath Ramsundar Committed by GitHub
Browse files

Merge pull request #1884 from lilleswing/pytest

Convert Nosetest to Pytest
parents 614d3591 f489c6f1
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -39,8 +39,7 @@ install:
  - pip install coveralls
  - python setup.py install
script:
  - nosetests -q --with-flaky -a '!slow' --with-coverage --cover-package=deepchem
    -v deepchem --nologcapture
  - pytest -m "not slow" --cov=deepchem deepchem
  - if [ $TRAVIS_PYTHON_VERSION == '3.7' ]; then
    find ./deepchem | grep .py$ |xargs python -m doctest -v;
    fi
+3 −4
Original line number Diff line number Diff line
from unittest import TestCase

from nose.tools import assert_equals
from nose.plugins.attrib import attr
import pytest
from rdkit import Chem

import deepchem as dc
@@ -12,7 +11,7 @@ from deepchem.models.autoencoder_models.autoencoder import TensorflowMoleculeEnc

class TestTensorflowEncoders(TestCase):

  @attr('slow')
  @pytest.mark.slow
  def test_fit(self):
    tf_enc = TensorflowMoleculeEncoder.zinc_encoder()

@@ -36,4 +35,4 @@ class TestTensorflowEncoders(TestCase):
    tf_de = TensorflowMoleculeDecoder.zinc_decoder()
    one_hot_decoded = tf_de.predict_on_batch(prediction)
    decoded_smiles = featurizer.untransform(one_hot_decoded)
    assert_equals(len(decoded_smiles), len(smiles))
    assert len(decoded_smiles) == len(smiles)
+3 −2
Original line number Diff line number Diff line
@@ -10,8 +10,9 @@ import logging
import unittest
import os
import numpy as np
import pytest

import deepchem as dc
from nose.tools import nottest
from deepchem.utils import rdkit_util

logger = logging.getLogger(__name__)
@@ -147,7 +148,7 @@ class TestBindingPocket(unittest.TestCase):

    assert len(pockets) < len(all_pockets)

  @nottest
  @pytest.mark.skip(reason="Unknown")
  def test_rf_convex_find_pockets(self):
    """Test that filter with pre-trained RF models works."""
    if sys.version_info >= (3, 0):
+10 −44
Original line number Diff line number Diff line
@@ -5,11 +5,12 @@ __author__ = "Bharath Ramsundar"
__copyright__ = "Copyright 2016, Stanford University"
__license__ = "MIT"

import unittest
import os
from nose.plugins.attrib import attr
from nose.tools import nottest
import sys
import unittest

import pytest

import deepchem as dc


@@ -18,14 +19,14 @@ class TestDocking(unittest.TestCase):
  Does sanity checks on pose generation.
  """

  @nottest
  @pytest.mark.skip(reason="Unknown")
  def test_vina_grid_rf_docker_init(self):
    """Test that VinaGridRFDocker can be initialized."""
    if sys.version_info >= (3, 0):
      return
    docker = dc.dock.VinaGridRFDocker(exhaustiveness=1, detect_pockets=False)

  @nottest
  @pytest.mark.skip(reason="Unknown")
  def test_pocket_vina_grid_rf_docker_init(self):
    """Test that VinaGridRFDocker w/pockets can be initialized."""
    if sys.version_info >= (3, 0):
@@ -45,7 +46,7 @@ class TestDocking(unittest.TestCase):
    docker = dc.dock.VinaGridDNNDocker(exhaustiveness=1, detect_pockets=True)
  '''

  @attr("slow")
  @pytest.mark.slow
  def test_vina_grid_rf_docker_dock(self):
    """Test that VinaGridRFDocker can dock."""
    if sys.version_info >= (3, 0):
@@ -64,7 +65,7 @@ class TestDocking(unittest.TestCase):
    assert os.path.exists(protein_docked)
    assert os.path.exists(ligand_docked)

  @nottest
  @pytest.mark.skip(reason="Unknown")
  def test_vina_grid_rf_docker_specified_pocket(self):
    """Test that VinaGridRFDocker can dock into spec. pocket."""
    if sys.version_info >= (3, 0):
@@ -85,7 +86,7 @@ class TestDocking(unittest.TestCase):
    # Check returned files exist
    assert score.shape == (1,)

  @nottest
  @pytest.mark.skip(reason="Unknown")
  def test_pocket_vina_grid_rf_docker_dock(self):
    """Test that VinaGridRFDocker can dock."""
    if sys.version_info >= (3, 0):
@@ -104,38 +105,3 @@ class TestDocking(unittest.TestCase):
      return

    assert score.shape == (1,)

  '''
  @attr("slow")
  def test_vina_grid_dnn_docker_dock(self):
    """Test that VinaGridDNNDocker can dock."""
    current_dir = os.path.dirname(os.path.realpath(__file__))
    protein_file = os.path.join(current_dir, "1jld_protein.pdb")
    ligand_file = os.path.join(current_dir, "1jld_ligand.sdf")

    docker = dc.dock.VinaGridDNNDocker(exhaustiveness=1, detect_pockets=False)
    (score, (protein_docked, ligand_docked)) = docker.dock(
        protein_file, ligand_file)

    # Check returned files exist
    assert score.shape == (1,)
    assert os.path.exists(protein_docked)
    assert os.path.exists(ligand_docked)

  @attr('slow')
  def test_pocket_vina_grid_dnn_docker_dock(self):
    """Test that VinaGridDNNDocker can dock."""
    if sys.version_info >= (3, 0):
      return

    current_dir = os.path.dirname(os.path.realpath(__file__))
    protein_file = os.path.join(current_dir, "1jld_protein.pdb")
    ligand_file = os.path.join(current_dir, "1jld_ligand.sdf")

    docker = dc.dock.VinaGridDNNDocker(exhaustiveness=1, detect_pockets=True)
    (score, (protein_docked, ligand_docked)) = docker.dock(
        protein_file, ligand_file, dry_run=True)

    # Check returned files exist
    assert score.shape == (1,)
  '''
+5 −5
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import os
import sys
import unittest
import deepchem as dc
from nose.plugins.attrib import attr
import pytest


class TestPoseGeneration(unittest.TestCase):
@@ -17,13 +17,13 @@ class TestPoseGeneration(unittest.TestCase):
  Does sanity checks on pose generation.
  """

  @attr("slow")
  @pytest.mark.slow
  def test_vina_initialization(self):
    """Test that VinaPoseGenerator can be initialized."""
    # Note this may download autodock Vina...
    vpg = dc.dock.VinaPoseGenerator(detect_pockets=False, exhaustiveness=1)

  @attr("slow")
  @pytest.mark.slow("slow")
  def test_pocket_vina_initialization(self):
    """Test that VinaPoseGenerator can be initialized."""
    # Note this may download autodock Vina...
@@ -31,7 +31,7 @@ class TestPoseGeneration(unittest.TestCase):
      return
    vpg = dc.dock.VinaPoseGenerator(detect_pockets=True, exhaustiveness=1)

  @attr("slow")
  @pytest.mark.slow("slow")
  def test_vina_poses(self):
    """Test that VinaPoseGenerator creates pose files."""
    current_dir = os.path.dirname(os.path.realpath(__file__))
@@ -47,7 +47,7 @@ class TestPoseGeneration(unittest.TestCase):
    assert os.path.exists(protein_pose_file)
    assert os.path.exists(ligand_pose_file)

  @attr('slow')
  @pytest.mark.slow('slow')
  def test_pocket_vina_poses(self):
    """Test that VinaPoseGenerator creates pose files."""
    if sys.version_info >= (3, 0):
Loading