diff --git a/setup.py b/setup.py
index <HASH>..<HASH> 100755
--- a/setup.py
+++ b/setup.py
@@ -8,7 +8,7 @@ os.environ['DJANGO_SETTINGS_MODULE'] = 'django_mailbox.tests.settings'
 
 from django.core import management
 
-if sys.argv[-1] == 'test':
+if len(sys.argv) > 1 and sys.argv[1] == 'test':
     management.execute_from_command_line()
     sys.exit()
Add support to args in tests