If you're interested in a runs test of randomness (which I suppose from your tags, but your text doesn't indicate), the Wald-Wolfowitz runs test conditions on the totals of the +/- counts, so it doesn't assume $p(+)=\frac{1}{2}$.
The Wald-Wolfowitz test (e.g. see Stephens, 1939) is a permutation test based on the total number of runs of both kinds, conditional on the total number of symbols of each kind.
I presume you're interested in too few runs (the usual case), which indicates "clumping of signs".
Your example data has 3 runs, with $n_+=7$ and $n_-=3$. There are 120 arrangements of the symbols, of which 2 have 2 runs (all + followed by all - and vice versa) and of the 3-run cases there are 2 with 7 "+"s in the center and 6 with 3 "-"s in the center, for a total of 10 cases with 3 or fewer runs:
2 runs:
--- +++++++
+++++++ ---
3 runs:
- +++++++ --
-- +++++++ -
+ --- ++++++
++ --- +++++
+++ --- ++++
++++ --- +++
+++++ --- ++
++++++ --- +
so the exact p-value of that case is 10/120.
It's a widely used test, most stats packages offer it in some way, though some only offer the asymptotic approximation (which works better with larger $n_+$ and $n_-$).
If you're interested in testing something else or using some different statistic, you'll need to say more.
(In R, randtests::runs.test
(on CRAN) can do the Wald-Wolfowitz test
(code -
as -1
and +
as 1
, and set the threshold to 0
); if your sample size is large enough to use the asymptotic approximation, it's easy to code by hand, in any case)
[1] Stevens W.L. (1939),
"Distribution of groups in a sequence of alternatives"
Annals of Eugenics 9:10-17