<commit_before># SmoothTest

[ ![Codeship Status for joaduo/smoothtest](https://codeship.com/projects/cdad4830-b21d-0132-82c3-62decd5a7cb3/status?branch=master)](https://codeship.com/projects/69981)

General purpose Testing Utilities and also special testing tools for Web Applications

## Better API for accessing Selenium

With smoothtest you can write nicer tests for web sites.

```python
class Home(TestCaseBase):

    _tested_page = '/'

    def test_home(self):
        self.browser.get_page(self._tested_page)
        self.assert_text('//p[@id="msg"]', u'Sign up to request beta access.')
        
    def test_empty_email(self):
        self.browser.get_page(self._tested_page)
        self.browser.click('//a[@class="new_job tab_link"]')
        class_ = self.browser.extract_xpath('//input[@name="email"]/@class')
        self.assertTrue('error' in class_.split(), 'No error style applied')

```

The API is very XPath oriented, so you can test your XPath with Firefox's extensions like FirePath.

## How to use smoothtest

The main utility is the `autotest` command. This command monitors your project's files and you unittest files for changes, it will trigger reloading and rerunning tests when a file changes. This means you can work in your code and see how tests are affected automatically. You can select a group of tests files to be monitored - that trigger partial reloads of those same modules -  and an group of files or directories to trigger full reloads of the project.

It also provides a ipython UI interface to modify certain values and re-test.

Do
```
python -m smoothtest.autotest.Command
```
To enter the Ipython UI without specifying any initial test.

If you want to start with a specific test, run this to get possible arguments.
```
python -m smoothtest.autotest.Command --help
```

Inside Ipython you you have to commands
```
%autotest
%test
%reset
%test_config
%get
%chrome
%firefox
%phantonjs
%steal_xpathbrowser
``` 
Where `%autotest` has same parameters as the `python -m smoothtest.autotest.Command` command but adds `-u` for updating test parameters and `-f` for forcing a reloading.

Autotest command is still in beta stage, so some functionality won't be as reliable as expected. (but still useful for developing tests) You may need to restart the autotest command from time to time.

## Configuration

You will need a `smoothtest_settings.py` in your `PYTHONPATH` that looks like this:

``` 
from smoothtest.settings.default import DefaultSettings
import logging

class Settings(DefaultSettings):<commit_msg>fix docs<commit_after># SmoothTest

[ ![Codeship Status for joaduo/smoothtest](https://codeship.com/projects/cdad4830-b21d-0132-82c3-62decd5a7cb3/status?branch=master)](https://codeship.com/projects/69981)

General purpose Testing Utilities and also special testing tools for Web Applications

## Better API for accessing Selenium

With smoothtest you can write nicer tests for web sites.

```python
class Home(TestCaseBase):

    _tested_page = '/'

    def test_home(self):
        self.browser.get_page(self._tested_page)
        self.assert_text('//p[@id="msg"]', u'Sign up to request beta access.')
        
    def test_empty_email(self):
        self.browser.get_page(self._tested_page)
        self.browser.click('//a[@class="new_job tab_link"]')
        class_ = self.browser.extract_xpath('//input[@name="email"]/@class')
        self.assertTrue('error' in class_.split(), 'No error style applied')

```

The API is very XPath oriented, so you can test your XPath with Firefox's extensions like FirePath.

## How to use smoothtest

The main utility is the `smoothtest` command. This command monitors your project's files and your unittest files for changes, it will trigger reloading and rerunning tests when a file changes. This means you can work in your code and see how tests are affected automatically. You can select a group of tests files to be monitored - that trigger partial reloads of those same modules -  and an group of files or directories to trigger full reloads of the project.

It also provides a ipython UI interface to modify certain values and re-test.

Do
```
smoothtest
```
To enter the Ipython UI without specifying any initial test.

If you want to start with a specific test, run this to get possible arguments.
```
python -m smoothtest.autotest.Command --help
```

Inside Ipython you you have to commands
```
%smoothtest
%test
%reset
%test_config
%get
%chrome
%firefox
%phantonjs
%steal_xpathbrowser
``` 
Where `%smoothtest` has same parameters as the `smoothtest` command but adds `-u` for updating test parameters and `-f` for forcing a reloading.

`smoothtest` command is still in beta stage, so some functionality won't be as reliable as expected. (but still useful for developing tests) You may need to restart the `smoothtest` command from time to time.

## Configuration

You will need a `smoothtest_settings.py` in your `PYTHONPATH` that looks like this:

``` 
from smoothtest.settings.default import DefaultSettings
import logging

class Settings(DefaultSettings):
{'fraction_non_alphanumeric': 0.08491311216429699, 'fraction_numerical': 0.009083728278041074, 'mean_word_length': 4.3428270042194095, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '697106', 'n_tokens_mistral': 1532, 'n_tokens_neox': 1436, 'n_words': 598}