Merge the test clients environ setup from Django master

I have noticed and compared it because of flake8 issues, and the only
non-whitespace changes are the addition of `str()` and `b''` wrappers.
Merge pull request #152 from blueyed/merge-django-test-client

Merge client environ setup from Django master
tests: use `dedent` with `extra_settings`, indent
django_testdir: use `ensure=True` with `write` for `create_*`
Merge pull request #154 from blueyed/testdir-use-dedent

tests: use more dedent and indenting
Check QA: add tasks to run flake8 to tox/travis

Also fix any current issues.