Skip to content

Commit

Permalink
Add tox config for word-count
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Oct 9, 2018
1 parent 39fa3db commit 4da9110
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -8,6 +8,9 @@ __pycache__/
.cache
.pytest_cache/
dist/
.tox/
.mypy_cache/
.hypothesis/

*.so
*.out
Expand Down
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -2,7 +2,6 @@

[![Build Status](https://travis-ci.org/PyO3/pyo3.svg?branch=master)](https://travis-ci.org/PyO3/pyo3)
[![Build Status](https://ci.appveyor.com/api/projects/status/github/PyO3/pyo3?branch=master&svg=true)](https://ci.appveyor.com/project/fafhrd91/pyo3)
[![codecov](https://codecov.io/gh/PyO3/pyo3/branch/master/graph/badge.svg)](https://codecov.io/gh/PyO3/pyo3)
[![crates.io](http://meritbadge.herokuapp.com/pyo3)](https://crates.io/crates/pyo3)
[![Join the dev chat](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/PyO3/Lobby)

Expand Down
6 changes: 0 additions & 6 deletions examples/rustapi_module/.gitignore

This file was deleted.

8 changes: 8 additions & 0 deletions examples/word-count/README.md
Expand Up @@ -24,4 +24,12 @@ There is a benchmark in `tests/test_word_count.py`:

```shell
pytest -v tests
```

## Testing

To test python 2.7, 3.5, 3.6 and 3.7, install tox globally and run

```shell
tox
```
3 changes: 3 additions & 0 deletions examples/word-count/requirements-dev.txt
@@ -0,0 +1,3 @@
pytest>=3.5.0
setuptools-rust>=0.10.2
pytest-benchmark>=3.1.1
4 changes: 2 additions & 2 deletions examples/word-count/src/lib.rs
Expand Up @@ -11,8 +11,8 @@ use rayon::prelude::*;
use std::fs;
use std::path::PathBuf;

#[pyclass]
/// Represents a file that can be searched
#[pyclass]
struct WordCounter {
path: PathBuf,
}
Expand Down Expand Up @@ -66,8 +66,8 @@ fn matches(word: &str, needle: &str) -> bool {
return needle.next().is_none();
}

#[pyfunction]
/// Count the occurences of needle in line, case insensitive
#[pyfunction]
fn count_line(line: &str, needle: &str) -> usize {
let mut total = 0;
for word in line.split(' ') {
Expand Down
14 changes: 14 additions & 0 deletions examples/word-count/tox.ini
@@ -0,0 +1,14 @@
[tox]
envlist = py27,
py35,
py36,
py37,
minversion = 3.4.0
skip_missing_interpreters = true

[testenv]
description = Run the unit tests under {basepython}
deps = -rrequirements-dev.txt
usedevelop = True
commands = pip install -e .
pytest tests
12 changes: 5 additions & 7 deletions src/class/methods.rs
@@ -1,12 +1,9 @@
// Copyright (c) 2017-present PyO3 Project and Contributors

use std;
use std::ffi::CString;

use ffi;
use libc::c_int;

static NO_PY_METHODS: &'static [PyMethodDefType] = &[];
use std;
use std::ffi::CString;

/// `PyMethodDefType` represents different types of python callable objects.
/// It is used by `#[pymethods]` and `#[pyproto]` annotations.
Expand Down Expand Up @@ -123,9 +120,10 @@ impl PySetterDef {
}

#[doc(hidden)]
/// The pymethods macro implements this trait so the methods are added to the object
pub trait PyMethodsProtocolImpl {
fn py_methods() -> &'static [PyMethodDefType] {
NO_PY_METHODS
&[]
}
}

Expand All @@ -134,7 +132,7 @@ impl<T> PyMethodsProtocolImpl for T {}
#[doc(hidden)]
pub trait PyPropMethodsProtocolImpl {
fn py_methods() -> &'static [PyMethodDefType] {
NO_PY_METHODS
&[]
}
}

Expand Down

0 comments on commit 4da9110

Please sign in to comment.