# Python Django tests not being split correctly

**URL:** <https://discuss.circleci.com/t/python-django-tests-not-being-split-correctly/36624>\
**Category:** Running Tests\
**Created:** [July 9, 2020, 11:47pm UTC](https://discuss.circleci.com/t/python-django-tests-not-being-split-correctly/36624 "2020-07-09T23:47:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![caleb15](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/caleb15/32/22646_2.png) [@caleb15](https://discuss.circleci.com/u/caleb15)\
**Post date:** [July 9, 2020, 11:47pm UTC](https://discuss.circleci.com/t/python-django-tests-not-being-split-correctly/36624/1 "2020-07-09T23:47:03Z")

</div>

When I split tests all the tests 532 of them go to one test container and the other containers don’t get anything.

Configuration:

```auto
  test-parallel:
    <<: *python-postgres
    parallelism: 4

    steps:
      - checkout
      - run: echo $(circleci tests glob "ff/mods/ **/tests/** /*.py" "ff/ **/tests.py" "ff/** /test_*.py" "ff/**/*_test.py" "ff/tests/*.py")
      - run: echo $(circleci tests glob "ff/mods/ **/tests/** /*.py" "ff/ **/tests.py" "ff/** /test_*.py" "ff/**/*_test.py" "ff/tests/*.py" | tr ' ' '\n' | wc -l)
      - run:
          name: test
          command: |
            # get test files while ignoring __init__ files
            TESTFILES=$(circleci tests glob "ff/mods/ **/tests/** /*.py" "ff/ **/tests.py" "ff/** /test_*.py" "ff/**/*_test.py" "ff/tests/*.py" | sed 's/\S\+ __init__.py//g')
            # reformat to remove duplicates, remove dups, reformat back
            echo $TESTFILES | tr ' ' '\n' | sort | uniq | tr '\n' ' ' > circleci_test_files.txt
            cat circleci_test_files.txt
            cat circleci_test_files.txt | tr ' ' '\n' | wc -l
            # split test files into seperate sets depending on parallel container
            TESTFILES=$(circleci tests split circleci_test_files.txt)
            # massage filepaths into format manage.py test accepts
            TESTFILES=$(echo $TESTFILES | tr "/" "." | sed 's/.py//g')
            echo $TESTFILES
            echo $TESTFILES | tr ' ' '\n' | wc -l

```

[https://app.circleci.com/pipelines/github/15five/fifteen5/31534/workflows/b76da46e-0501-42eb-92e6-417c7ea57f3c/jobs/193895/parallel-runs/0?filterBy=ALL](https://app.circleci.com/pipelines/github/15five/fifteen5/31534/workflows/b76da46e-0501-42eb-92e6-417c7ea57f3c/jobs/193895/parallel-runs/0?filterBy=ALL)

```auto
ff/core/permissions/tests.py ... output truncated ... ff/tests/test_sanitize.py ff/tests/test_serializers.py ff/tests/test_user.py 532
ff.core.permissions.tests ...output truncated... ff.tests.test_user
532
CircleCI received exit code 0

```

[https://app.circleci.com/pipelines/github/15five/fifteen5/31534/workflows/b76da46e-0501-42eb-92e6-417c7ea57f3c/jobs/193895/parallel-runs/1?filterBy=ALL](https://app.circleci.com/pipelines/github/15five/fifteen5/31534/workflows/b76da46e-0501-42eb-92e6-417c7ea57f3c/jobs/193895/parallel-runs/1?filterBy=ALL)

```auto
ff/core/permissions/tests.py ... output truncated ... ff/tests/test_serializers.py ff/tests/test_user.py 532

1
CircleCI received exit code 0

```

---

<div class="post-metadata">

**Author:** ![caleb15](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/caleb15/32/22646_2.png) [@caleb15](https://discuss.circleci.com/u/caleb15)\
**Post date:** [July 9, 2020, 11:47pm UTC](https://discuss.circleci.com/t/python-django-tests-not-being-split-correctly/36624/2 "2020-07-09T23:47:38Z")

</div>

I also tried with echoing $TESTFILES directly into circleci tests split but that didn’t work either

---

<div class="post-metadata">

**Author:** ![caleb15](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/caleb15/32/22646_2.png) [@caleb15](https://discuss.circleci.com/u/caleb15)\
**Post date:** [July 10, 2020, 7:20pm UTC](https://discuss.circleci.com/t/python-django-tests-not-being-split-correctly/36624/3 "2020-07-10T19:20:37Z")

</div>

Fixed - I just removed `| tr '\n' ' ' ` from `echo $TESTFILES | tr ' ' '\n' | sort | uniq | tr '\n' ' ' > circleci_test_files.txt` and it worked

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [July 20, 2020, 7:20pm UTC](https://discuss.circleci.com/t/python-django-tests-not-being-split-correctly/36624/4 "2020-07-20T19:20:41Z")

</div>

Closed on July 20, 2020, 7:20pm UTC

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
